|
@@ -429,78 +429,6 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum,
|
|
|
nilfs_mdt_mark_dirty(sufile);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * nilfs_sufile_get_segment_usage - get a segment usage
|
|
|
- * @sufile: inode of segment usage file
|
|
|
- * @segnum: segment number
|
|
|
- * @sup: pointer to segment usage
|
|
|
- * @bhp: pointer to buffer head
|
|
|
- *
|
|
|
- * Description: nilfs_sufile_get_segment_usage() acquires the segment usage
|
|
|
- * specified by @segnum.
|
|
|
- *
|
|
|
- * Return Value: On success, 0 is returned, and the segment usage and the
|
|
|
- * buffer head of the buffer on which the segment usage is located are stored
|
|
|
- * in the place pointed by @sup and @bhp, respectively. On error, one of the
|
|
|
- * following negative error codes is returned.
|
|
|
- *
|
|
|
- * %-EIO - I/O error.
|
|
|
- *
|
|
|
- * %-ENOMEM - Insufficient amount of memory available.
|
|
|
- *
|
|
|
- * %-EINVAL - Invalid segment usage number.
|
|
|
- */
|
|
|
-int nilfs_sufile_get_segment_usage(struct inode *sufile, __u64 segnum,
|
|
|
- struct nilfs_segment_usage **sup,
|
|
|
- struct buffer_head **bhp)
|
|
|
-{
|
|
|
- struct buffer_head *bh;
|
|
|
- struct nilfs_segment_usage *su;
|
|
|
- void *kaddr;
|
|
|
- int ret;
|
|
|
-
|
|
|
- /* segnum is 0 origin */
|
|
|
- if (segnum >= nilfs_sufile_get_nsegments(sufile))
|
|
|
- return -EINVAL;
|
|
|
- down_write(&NILFS_MDT(sufile)->mi_sem);
|
|
|
- ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, &bh);
|
|
|
- if (ret < 0)
|
|
|
- goto out_sem;
|
|
|
- kaddr = kmap(bh->b_page);
|
|
|
- su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr);
|
|
|
- if (nilfs_segment_usage_error(su)) {
|
|
|
- kunmap(bh->b_page);
|
|
|
- brelse(bh);
|
|
|
- ret = -EINVAL;
|
|
|
- goto out_sem;
|
|
|
- }
|
|
|
-
|
|
|
- if (sup != NULL)
|
|
|
- *sup = su;
|
|
|
- *bhp = bh;
|
|
|
-
|
|
|
- out_sem:
|
|
|
- up_write(&NILFS_MDT(sufile)->mi_sem);
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * nilfs_sufile_put_segment_usage - put a segment usage
|
|
|
- * @sufile: inode of segment usage file
|
|
|
- * @segnum: segment number
|
|
|
- * @bh: buffer head
|
|
|
- *
|
|
|
- * Description: nilfs_sufile_put_segment_usage() releases the segment usage
|
|
|
- * specified by @segnum. @bh must be the buffer head which have been returned
|
|
|
- * by a previous call to nilfs_sufile_get_segment_usage() with @segnum.
|
|
|
- */
|
|
|
-void nilfs_sufile_put_segment_usage(struct inode *sufile, __u64 segnum,
|
|
|
- struct buffer_head *bh)
|
|
|
-{
|
|
|
- kunmap(bh->b_page);
|
|
|
- brelse(bh);
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* nilfs_sufile_mark_dirty - mark the buffer having a segment usage dirty
|
|
|
* @sufile: inode of segment usage file
|