Skip to content

Commit

Permalink
vfs: guard end of device for mpage interface
Browse files Browse the repository at this point in the history
Add guard_bio_eod() check for mpage code in order to allow us to do IO
even on the odd last sectors of a device, even if the block size is some
multiple of the physical sector size.

Using mpage_readpages() for block device requires this guard check.

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Jeff Moyer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Oct 10, 2014
1 parent 59d4391 commit 4db96b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2966,7 +2966,7 @@ static void end_bio_bh_io_sync(struct bio *bio, int err)
* errors, this only handles the "we need to be able to
* do IO at the final sector" case.
*/
static void guard_bio_eod(int rw, struct bio *bio)
void guard_bio_eod(int rw, struct bio *bio)
{
sector_t maxsector;
struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
Expand Down
5 changes: 5 additions & 0 deletions fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait)
}
#endif

/*
* buffer.c
*/
extern void guard_bio_eod(int rw, struct bio *bio);

/*
* char_dev.c
*/
Expand Down
2 changes: 2 additions & 0 deletions fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/backing-dev.h>
#include <linux/pagevec.h>
#include <linux/cleancache.h>
#include "internal.h"

/*
* I/O completion handler for multipage BIOs.
Expand Down Expand Up @@ -57,6 +58,7 @@ static void mpage_end_io(struct bio *bio, int err)
static struct bio *mpage_bio_submit(int rw, struct bio *bio)
{
bio->bi_end_io = mpage_end_io;
guard_bio_eod(rw, bio);
submit_bio(rw, bio);
return NULL;
}
Expand Down

0 comments on commit 4db96b7

Please sign in to comment.