Remove BKL removal patches, since they don't seem to be portable on
[ext4-patch-queue.git] / add-buffer-head-related-helper-functions.patch
blob25ddabdb2da546df55c1eab29d0badffe1e20628
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 | 44 +++++++++++++++++++++++++++++++++++++++++++
12 include/linux/buffer_head.h | 2 ++
13 2 files changed, 46 insertions(+), 0 deletions(-)
16 diff --git a/fs/buffer.c b/fs/buffer.c
17 index 7249e01..456c9ab 100644
18 --- a/fs/buffer.c
19 +++ b/fs/buffer.c
20 @@ -3213,6 +3213,50 @@ 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);
43 +/**
44 + * bh_submit_read: Submit a locked buffer for reading
45 + * @bh: struct buffer_head
46 + *
47 + * Returns zero on success and -EIO on error.
48 + */
49 +int bh_submit_read(struct buffer_head *bh)
51 + BUG_ON(!buffer_locked(bh));
53 + if (buffer_uptodate(bh)) {
54 + unlock_buffer(bh);
55 + return 0;
56 + }
58 + get_bh(bh);
59 + bh->b_end_io = end_buffer_read_sync;
60 + submit_bh(READ, bh);
61 + wait_on_buffer(bh);
62 + if (buffer_uptodate(bh))
63 + return 0;
64 + return -EIO;
66 +EXPORT_SYMBOL(bh_submit_read);
68 void __init buffer_init(void)
70 int nrpages;
71 diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
72 index da0d83f..e98801f 100644
73 --- a/include/linux/buffer_head.h
74 +++ b/include/linux/buffer_head.h
75 @@ -192,6 +192,8 @@ int sync_dirty_buffer(struct buffer_head *bh);
76 int submit_bh(int, struct buffer_head *);
77 void write_boundary_block(struct block_device *bdev,
78 sector_t bblock, unsigned blocksize);
79 +int bh_uptodate_or_lock(struct buffer_head *bh);
80 +int bh_submit_read(struct buffer_head *bh);
82 extern int buffer_heads_over_limit;