hfsplus: rework hfsplus_submit_bio() method
Subsystems (2)
Vyacheslav Dubeyko
maintainerPATCH v3 2/15 hfsplus: rework hfsplus_submit_bio() method
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH v3 02/15] hfsplus: rework hfsplus_submit_bio() method
This patch reworks hfsplus_submit_bio() method with the goal to get length of data from address of data pointer till the end of data block.
Signed-off-by Vyacheslav Dubeyko <[email protected]>
CC Al Viro <[email protected]>
CC Christoph Hellwig <[email protected]>
Tested-by Hin-Tak Leung <[email protected]>
--- fs/hfsplus/hfsplus_fs.h | 2 +- fs/hfsplus/part_tbl.c | 4 ++-- fs/hfsplus/super.c | 5 +++-- fs/hfsplus/wrapper.c | 28 +++++++++++++++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-)
fs/hfsplus/hfsplus_fs.h +1 -1
@@ -537,7 +537,7 @@ int hfsplus_compare_dentry(const struct dentry *parent, const struct dentry *denint hfsplus_read_wrapper (struct super_block *);int hfs_part_find (struct super_block *,sector_t *,sector_t *);int hfsplus_submit_bio (struct super_block *sb,sector_t sector, -void *buf,void **data,int rw); +void *buf,void **data,int rw,size_t *data_len);/* time macros */ #define __hfsp_mt2ut (t) (be32_to_cpu(t) - 2082844800U)
fs/hfsplus/part_tbl.c +2 -2
@@ -112,7 +112,7 @@ static int hfs_parse_new_pmap(struct super_block *sb, void *buf,if ((u8 *)pm - (u8 *)buf >= buf_size) { res =hfsplus_submit_bio (sb, *part_start +HFS_PMAP_BLK + i, - buf, (void **)&pm,READ ); + buf, (void **)&pm,READ ,NULL );if (res)return res; }
@@ -136,7 +136,7 @@ int hfs_part_find(struct super_block *sb,return -ENOMEM ; res =hfsplus_submit_bio (sb, *part_start +HFS_PMAP_BLK , - buf, &data,READ ); + buf, &data,READ ,NULL );if (res) goto out;
fs/hfsplus/super.c +3 -2
@@ -217,7 +217,7 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait) error2 =hfsplus_submit_bio (sb, sbi->part_start +HFSPLUS_VOLHEAD_SECTOR , - sbi->s_vhdr_buf,NULL ,WRITE_SYNC ); + sbi->s_vhdr_buf,NULL ,WRITE_SYNC ,NULL );if (!error) error = error2;if (!write_backup)
@@ -225,7 +225,8 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait) error2 =hfsplus_submit_bio (sb, sbi->part_start + sbi->sect_count -2 , - sbi->s_backup_vhdr_buf,NULL ,WRITE_SYNC ); + sbi->s_backup_vhdr_buf,NULL ,WRITE_SYNC , +NULL );if (!error) error2 = error; out:
fs/hfsplus/wrapper.c +21 -7
@@ -31,6 +31,7 @@ struct hfsplus_wd {* @buf: buffer for I/O * @data: output pointer for location of requested data * @rw: direction of I/O +* @data_len: output pointer for length of requested data * * The unit of I/O is hfsplus_min_io_size(sb), which may be bigger than * HFSPLUS_SECTOR_SIZE, and @buf must be sized accordingly. On reads
@@ -44,13 +45,14 @@ struct hfsplus_wd {* will work correctly. */ int hfsplus_submit_bio (struct super_block *sb,sector_t sector, -void *buf,void **data,int rw) +void *buf,void **data,int rw,size_t *data_len) {struct bio *bio;int ret =0 ;u64 io_size;loff_t start;int offset; +unsigned int page_offset;/* * Align sector to hardware sector size and find offset. We
@@ -66,13 +68,25 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector, bio->bi_iter.bi_sector = sector; bio->bi_bdev = sb->s_bdev; -if (!(rw &WRITE ) && data) +if (!(rw &WRITE ) && data) { *data = (u8 *)buf + offset; +if (data_len) { + page_offset =offset_in_page (buf); + +BUG_ON (offset > io_size); +BUG_ON ((page_offset + offset) >PAGE_SIZE ); + + *data_len =min_t (size_t, io_size - offset, +PAGE_SIZE - page_offset - offset); + } + } +while (io_size >0 ) { -unsigned int page_offset =offset_in_page (buf); - unsigned int len = min_t(unsigned int, PAGE_SIZE - page_offset, - io_size); +unsigned int len; + + page_offset =offset_in_page (buf); + len = min_t(unsigned int, PAGE_SIZE - page_offset, io_size); ret =bio_add_page (bio,virt_to_page (buf), len, page_offset);if (ret != len) {
@@ -181,7 +195,7 @@ int hfsplus_read_wrapper(struct super_block *sb) reread: error =hfsplus_submit_bio (sb, part_start +HFSPLUS_VOLHEAD_SECTOR , sbi->s_vhdr_buf, (void **)&sbi->s_vhdr, -READ ); +READ ,NULL );if (error) goto out_free_backup_vhdr;
@@ -213,7 +227,7 @@ reread: error =hfsplus_submit_bio (sb, part_start + part_size -2 , sbi->s_backup_vhdr_buf, - (void **)&sbi->s_backup_vhdr,READ ); + (void **)&sbi->s_backup_vhdr,READ ,NULL );if (error) goto out_free_backup_vhdr;
Signature · 1 line
1.7.9.5