From: Sergei Antonov <saproj@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: Anton Altaparmakov <aia21@cam.ac.uk>,
Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Vyacheslav Dubeyko <slava@dubeyko.com>,
Hin-Tak Leung <htl10@users.sourceforge.net>,
Sougata Santra <sougata@tuxera.com>,
Sergei Antonov <saproj@gmail.com>
Subject: [PATCH] hfsplus: fix cross-page bio requests
Date: Fri, 10 Apr 2015 11:02:23 +0200 [thread overview]
Message-ID: <1428656543-6790-1-git-send-email-saproj@gmail.com> (raw)
Function hfsplus_submit_bio() did not work when the passed buffer spanned
over more than one page. That was because bio_alloc() is passed 1 as a number
of vectors but more than one vector were added inside the 'while' loop.
It periodically caused a mount error when the volume header could not be read.
This patch modifies the code so that only one vector is used. It works for
multiple pages too. Also adds a return code check after bio_alloc().
Cc: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Vyacheslav Dubeyko <slava@dubeyko.com>
Cc: Hin-Tak Leung <htl10@users.sourceforge.net>
Cc: Sougata Santra <sougata@tuxera.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
fs/hfsplus/wrapper.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index cc62356..e245faa 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -62,29 +62,20 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
offset = start & (io_size - 1);
sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1);
- bio = bio_alloc(GFP_NOIO, 1);
- bio->bi_iter.bi_sector = sector;
- bio->bi_bdev = sb->s_bdev;
-
if (!(rw & WRITE) && data)
*data = (u8 *)buf + 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);
-
- ret = bio_add_page(bio, virt_to_page(buf), len, page_offset);
- if (ret != len) {
- ret = -EIO;
- goto out;
- }
- io_size -= len;
- buf = (u8 *)buf + len;
- }
-
+ bio = bio_alloc(GFP_NOIO, 1);
+ if (!bio)
+ return -ENOMEM;
+ bio->bi_iter.bi_sector = sector;
+ bio->bi_bdev = sb->s_bdev;
+ bio->bi_vcnt = 1;
+ bio->bi_iter.bi_size = io_size;
+ bio->bi_io_vec[0].bv_page = virt_to_page(buf);
+ bio->bi_io_vec[0].bv_offset = offset_in_page(buf);
+ bio->bi_io_vec[0].bv_len = io_size;
ret = submit_bio_wait(rw, bio);
-out:
bio_put(bio);
return ret < 0 ? ret : 0;
}
--
2.3.0
next reply other threads:[~2015-04-10 7:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 9:02 Sergei Antonov [this message]
2015-04-10 16:48 ` [PATCH] hfsplus: fix cross-page bio requests Viacheslav Dubeyko
2015-06-07 20:05 ` Sergei Antonov
2015-06-07 20:09 ` Sergei Antonov
2015-06-08 17:03 ` Viacheslav Dubeyko
2015-06-08 17:20 ` Sergei Antonov
2015-06-09 16:36 ` Viacheslav Dubeyko
2015-06-09 22:32 ` Anton Altaparmakov
2015-06-09 23:53 ` Sergei Antonov
2015-06-10 5:05 ` hch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428656543-6790-1-git-send-email-saproj@gmail.com \
--to=saproj@gmail.com \
--cc=aia21@cam.ac.uk \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=htl10@users.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=sougata@tuxera.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).