aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2005-09-06 18:19:10 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:55 -0400
commita7662236253374012d364106b6dc9161bd929e2e (patch)
tree59f34811d18fef8195bc3200bdb2684598175f29
parente6c9f5c1888097c936334bf9740024520ca47b8e (diff)
[PATCH] Make ll_rw_block() wait for buffer lock
Introduce new ll_rw_block() operation SWRITE meaning that block layer should wait for the buffer lock and write-out afterwards. Hence data in buffers at the time of call are guaranteed to be submitted to the disk. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/buffer.c30
-rw-r--r--include/linux/fs.h1
2 files changed, 17 insertions, 14 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index a92b81403552..1c62203a4906 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -917,8 +917,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list)
917 * contents - it is a noop if I/O is still in 917 * contents - it is a noop if I/O is still in
918 * flight on potentially older contents. 918 * flight on potentially older contents.
919 */ 919 */
920 wait_on_buffer(bh); 920 ll_rw_block(SWRITE, 1, &bh);
921 ll_rw_block(WRITE, 1, &bh);
922 brelse(bh); 921 brelse(bh);
923 spin_lock(lock); 922 spin_lock(lock);
924 } 923 }
@@ -2793,21 +2792,22 @@ int submit_bh(int rw, struct buffer_head * bh)
2793 2792
2794/** 2793/**
2795 * ll_rw_block: low-level access to block devices (DEPRECATED) 2794 * ll_rw_block: low-level access to block devices (DEPRECATED)
2796 * @rw: whether to %READ or %WRITE or maybe %READA (readahead) 2795 * @rw: whether to %READ or %WRITE or %SWRITE or maybe %READA (readahead)
2797 * @nr: number of &struct buffer_heads in the array 2796 * @nr: number of &struct buffer_heads in the array
2798 * @bhs: array of pointers to &struct buffer_head 2797 * @bhs: array of pointers to &struct buffer_head
2799 * 2798 *
2800 * ll_rw_block() takes an array of pointers to &struct buffer_heads, 2799 * ll_rw_block() takes an array of pointers to &struct buffer_heads, and
2801 * and requests an I/O operation on them, either a %READ or a %WRITE. 2800 * requests an I/O operation on them, either a %READ or a %WRITE. The third
2802 * The third %READA option is described in the documentation for 2801 * %SWRITE is like %WRITE only we make sure that the *current* data in buffers
2803 * generic_make_request() which ll_rw_block() calls. 2802 * are sent to disk. The fourth %READA option is described in the documentation
2803 * for generic_make_request() which ll_rw_block() calls.
2804 * 2804 *
2805 * This function drops any buffer that it cannot get a lock on (with the 2805 * This function drops any buffer that it cannot get a lock on (with the
2806 * BH_Lock state bit), any buffer that appears to be clean when doing a 2806 * BH_Lock state bit) unless SWRITE is required, any buffer that appears to be
2807 * write request, and any buffer that appears to be up-to-date when doing 2807 * clean when doing a write request, and any buffer that appears to be
2808 * read request. Further it marks as clean buffers that are processed for 2808 * up-to-date when doing read request. Further it marks as clean buffers that
2809 * writing (the buffer cache won't assume that they are actually clean until 2809 * are processed for writing (the buffer cache won't assume that they are
2810 * the buffer gets unlocked). 2810 * actually clean until the buffer gets unlocked).
2811 * 2811 *
2812 * ll_rw_block sets b_end_io to simple completion handler that marks 2812 * ll_rw_block sets b_end_io to simple completion handler that marks
2813 * the buffer up-to-date (if approriate), unlocks the buffer and wakes 2813 * the buffer up-to-date (if approriate), unlocks the buffer and wakes
@@ -2823,11 +2823,13 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
2823 for (i = 0; i < nr; i++) { 2823 for (i = 0; i < nr; i++) {
2824 struct buffer_head *bh = bhs[i]; 2824 struct buffer_head *bh = bhs[i];
2825 2825
2826 if (test_set_buffer_locked(bh)) 2826 if (rw == SWRITE)
2827 lock_buffer(bh);
2828 else if (test_set_buffer_locked(bh))
2827 continue; 2829 continue;
2828 2830
2829 get_bh(bh); 2831 get_bh(bh);
2830 if (rw == WRITE) { 2832 if (rw == WRITE || rw == SWRITE) {
2831 if (test_clear_buffer_dirty(bh)) { 2833 if (test_clear_buffer_dirty(bh)) {
2832 bh->b_end_io = end_buffer_write_sync; 2834 bh->b_end_io = end_buffer_write_sync;
2833 submit_bh(WRITE, bh); 2835 submit_bh(WRITE, bh);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7e1b589842af..fd93ab7da905 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -69,6 +69,7 @@ extern int dir_notify_enable;
69#define READ 0 69#define READ 0
70#define WRITE 1 70#define WRITE 1
71#define READA 2 /* read-ahead - don't block if no resources */ 71#define READA 2 /* read-ahead - don't block if no resources */
72#define SWRITE 3 /* for ll_rw_block() - wait for buffer lock */
72#define SPECIAL 4 /* For non-blockdevice requests in request queue */ 73#define SPECIAL 4 /* For non-blockdevice requests in request queue */
73#define READ_SYNC (READ | (1 << BIO_RW_SYNC)) 74#define READ_SYNC (READ | (1 << BIO_RW_SYNC))
74#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) 75#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))