* [PATCH v4 02/15] hfsplus: rework hfsplus_submit_bio() method
@ 2014-02-23 15:32 Vyacheslav Dubeyko
0 siblings, 0 replies; only message in thread
From: Vyacheslav Dubeyko @ 2014-02-23 15:32 UTC (permalink / raw)
To: Linux FS devel list
Cc: Al Viro, ChristophHellwig, Hin-Tak Leung, Andrew Morton
From: Vyacheslav Dubeyko <slava@dubeyko.com>
Subject: [PATCH v4 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 <slava@dubeyko.com>
CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Christoph Hellwig <hch@infradead.org>
Tested-by: Hin-Tak Leung <htl10@users.sourceforge.net>
---
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(-)
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 2353eaa..02a7241 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -549,7 +549,7 @@ int hfsplus_compare_dentry(const struct dentry *parent, const struct dentry *den
int 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)
diff --git a/fs/hfsplus/part_tbl.c b/fs/hfsplus/part_tbl.c
index eb355d8..f7c8ebf 100644
--- a/fs/hfsplus/part_tbl.c
+++ b/fs/hfsplus/part_tbl.c
@@ -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;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 80875aa..12eaf33 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -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:
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 3f99964..8936904 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -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;
--
1.7.9.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-23 15:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-23 15:32 [PATCH v4 02/15] hfsplus: rework hfsplus_submit_bio() method Vyacheslav Dubeyko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).