More patch description fixups. Standardize case.
[ext4-patch-queue.git] / add-buffer-head-related-helper-functions.patch
blob9cefc562bf6c6b94f588ef8d277ec2fd060790a1
1 Add buffer head related helper functions
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 Add buffer head related helper function bh_uptodate_or_lock and
6 bh_submit_read which can be used by file system
8 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 ---
11 fs/buffer.c | 41 +++++++++++++++++++++++++++++++++++++++++
12 include/linux/buffer_head.h | 2 ++
13 2 files changed, 43 insertions(+), 0 deletions(-)
16 diff --git a/fs/buffer.c b/fs/buffer.c
17 index 7249e01..7593ff3 100644
18 --- a/fs/buffer.c
19 +++ b/fs/buffer.c
20 @@ -3213,6 +3213,47 @@ static int buffer_cpu_notify(struct notifier_block *self,
21 return NOTIFY_OK;
24 +/**
25 + * bh_uptodate_or_lock: Test whether the buffer is uptodate
26 + * @bh: struct buffer_head
27 + *
28 + * Return true if the buffer is up-to-date and false,
29 + * with the buffer locked, if not.
30 + */
31 +int bh_uptodate_or_lock(struct buffer_head *bh)
33 + if (!buffer_uptodate(bh)) {
34 + lock_buffer(bh);
35 + if (!buffer_uptodate(bh))
36 + return 0;
37 + unlock_buffer(bh);
38 + }
39 + return 1;
41 +EXPORT_SYMBOL(bh_uptodate_or_lock);
42 +/**
43 + * bh_submit_read: Submit a locked buffer for reading
44 + * @bh: struct buffer_head
45 + *
46 + * Returns a negative error
47 + */
48 +int bh_submit_read(struct buffer_head *bh)
50 + if (!buffer_locked(bh))
51 + lock_buffer(bh);
53 + if (buffer_uptodate(bh))
54 + return 0;
56 + get_bh(bh);
57 + bh->b_end_io = end_buffer_read_sync;
58 + submit_bh(READ, bh);
59 + wait_on_buffer(bh);
60 + if (buffer_uptodate(bh))
61 + return 0;
62 + return -EIO;
64 +EXPORT_SYMBOL(bh_submit_read);
65 void __init buffer_init(void)
67 int nrpages;
68 diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
69 index da0d83f..e98801f 100644
70 --- a/include/linux/buffer_head.h
71 +++ b/include/linux/buffer_head.h
72 @@ -192,6 +192,8 @@ int sync_dirty_buffer(struct buffer_head *bh);
73 int submit_bh(int, struct buffer_head *);
74 void write_boundary_block(struct block_device *bdev,
75 sector_t bblock, unsigned blocksize);
76 +int bh_uptodate_or_lock(struct buffer_head *bh);
77 +int bh_submit_read(struct buffer_head *bh);
79 extern int buffer_heads_over_limit;