diff options
| -rw-r--r-- | fs/buffer.c | 12 | ||||
| -rw-r--r-- | include/linux/buffer_head.h | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 277147586fda..e2fdba6182a6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2868,20 +2868,26 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[]) /* * For a data-integrity writeout, we need to wait upon any in-progress I/O - * and then start new I/O and then wait upon it. + * and then start new I/O and then wait upon it. The caller must have a ref on + * the buffer_head. */ -void sync_dirty_buffer(struct buffer_head *bh) +int sync_dirty_buffer(struct buffer_head *bh) { + int ret = 0; + WARN_ON(atomic_read(&bh->b_count) < 1); lock_buffer(bh); if (test_clear_buffer_dirty(bh)) { get_bh(bh); bh->b_end_io = end_buffer_write_sync; - submit_bh(WRITE, bh); + ret = submit_bh(WRITE, bh); wait_on_buffer(bh); + if (!ret && !buffer_uptodate(bh)) + ret = -EIO; } else { unlock_buffer(bh); } + return ret; } /* diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index b94bd82e6099..ef849b7a1f6d 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -174,7 +174,7 @@ void free_buffer_head(struct buffer_head * bh); void FASTCALL(unlock_buffer(struct buffer_head *bh)); void FASTCALL(__lock_buffer(struct buffer_head *bh)); void ll_rw_block(int, int, struct buffer_head * bh[]); -void sync_dirty_buffer(struct buffer_head *bh); +int sync_dirty_buffer(struct buffer_head *bh); int submit_bh(int, struct buffer_head *); void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize); |
