From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Theodore Ts'o" <tytso@MIT.EDU>,
linux-kernel@vger.kernel.org,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 23/49] Add buffer head related helper functions
Date: Thu, 24 Jan 2008 10:52:27 +0530 [thread overview]
Message-ID: <20080124052227.GA7902@skywalker> (raw)
In-Reply-To: <20080123140648.788fbc49.akpm@linux-foundation.org>
On Wed, Jan 23, 2008 at 02:06:48PM -0800, Andrew Morton wrote:
> > On Mon, 21 Jan 2008 22:02:02 -0500 "Theodore Ts'o" <tytso@MIT.EDU> wrote:
> > +}
> > +EXPORT_SYMBOL(bh_uptodate_or_lock);
> > +/**
>
> Missing newline.
>
> > + * bh_submit_read: Submit a locked buffer for reading
> > + * @bh: struct buffer_head
> > + *
> > + * Returns a negative error
> > + */
> > +int bh_submit_read(struct buffer_head *bh)
> > +{
> > + if (!buffer_locked(bh))
> > + lock_buffer(bh);
> > +
> > + if (buffer_uptodate(bh))
> > + return 0;
>
> Here it can lock the buffer then return zero
>
> > + get_bh(bh);
> > + bh->b_end_io = end_buffer_read_sync;
> > + submit_bh(READ, bh);
> > + wait_on_buffer(bh);
> > + if (buffer_uptodate(bh))
> > + return 0;
>
> Here it will unlock the buffer and return zero.
>
> This function is unusable when passed an unlocked buffer.
>
Updated patch below.
commit 70d4ca32604e0935a8b9a49c5ac8b9c64c810693
Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Date: Thu Jan 24 10:50:24 2008 +0530
Add buffer head related helper functions
Add buffer head related helper function bh_uptodate_or_lock and
bh_submit_read which can be used by file system
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
diff --git a/fs/buffer.c b/fs/buffer.c
index 7249e01..82aa2db 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3213,6 +3213,53 @@ static int buffer_cpu_notify(struct notifier_block *self,
return NOTIFY_OK;
}
+/**
+ * bh_uptodate_or_lock: Test whether the buffer is uptodate
+ * @bh: struct buffer_head
+ *
+ * Return true if the buffer is up-to-date and false,
+ * with the buffer locked, if not.
+ */
+int bh_uptodate_or_lock(struct buffer_head *bh)
+{
+ if (!buffer_uptodate(bh)) {
+ lock_buffer(bh);
+ if (!buffer_uptodate(bh))
+ return 0;
+ unlock_buffer(bh);
+ }
+ return 1;
+}
+EXPORT_SYMBOL(bh_uptodate_or_lock);
+
+/**
+ * bh_submit_read: Submit a locked buffer for reading
+ * @bh: struct buffer_head
+ *
+ * Returns zero on success and -EIO on error.If the input
+ * buffer is not locked returns -EINVAL
+ *
+ */
+int bh_submit_read(struct buffer_head *bh)
+{
+ if (!buffer_locked(bh))
+ return -EINVAL;
+
+ if (buffer_uptodate(bh)) {
+ unlock_buffer(bh);
+ return 0;
+ }
+
+ get_bh(bh);
+ bh->b_end_io = end_buffer_read_sync;
+ submit_bh(READ, bh);
+ wait_on_buffer(bh);
+ if (buffer_uptodate(bh))
+ return 0;
+ return -EIO;
+}
+EXPORT_SYMBOL(bh_submit_read);
+
void __init buffer_init(void)
{
int nrpages;
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index da0d83f..e98801f 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -192,6 +192,8 @@ 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);
+int bh_uptodate_or_lock(struct buffer_head *bh);
+int bh_submit_read(struct buffer_head *bh);
extern int buffer_heads_over_limit;
next prev parent reply other threads:[~2008-01-24 5:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1200970948-17903-1-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-2-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-3-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-4-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-5-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-6-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-7-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-8-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-9-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-10-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-11-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-12-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-13-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-14-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-15-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-16-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-17-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-18-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-19-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-20-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-21-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-22-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-23-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-24-git-send-email-tytso@mit.edu>
2008-01-23 22:06 ` [PATCH 23/49] Add buffer head related helper functions Andrew Morton
2008-01-24 5:22 ` Aneesh Kumar K.V [this message]
2008-01-24 8:53 ` Andrew Morton
[not found] ` <1200970948-17903-25-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-26-git-send-email-tytso@mit.edu>
2008-01-22 3:02 ` [PATCH 26/49] jbd2: Fix assertion failure in fs/jbd2/checkpoint.c Theodore Ts'o
[not found] ` <1200970948-17903-28-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-29-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-30-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-31-git-send-email-tytso@mit.edu>
2008-01-23 22:06 ` [PATCH 30/49] ext4: Convert truncate_mutex to read write semaphore Andrew Morton
2008-01-24 5:29 ` Aneesh Kumar K.V
2008-01-24 13:00 ` Andy Whitcroft
[not found] ` <1200970948-17903-32-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-33-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-34-git-send-email-tytso@mit.edu>
2008-01-23 22:07 ` [PATCH 33/49] ext4: Add the journal checksum feature Andrew Morton
2008-01-23 22:40 ` Andreas Dilger
2008-01-24 21:24 ` Mingming Cao
2008-02-01 20:50 ` Girish Shilamkar
[not found] ` <1200970948-17903-35-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-36-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-37-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-38-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-39-git-send-email-tytso@mit.edu>
2008-01-22 3:02 ` [PATCH 39/49] ext4: Add ext4_find_next_bit() Theodore Ts'o
[not found] ` <1200970948-17903-41-git-send-email-tytso@mit.edu>
[not found] ` <1200970948-17903-42-git-send-email-tytso@mit.edu>
2008-01-23 22:07 ` [PATCH 41/49] ext4: Add multi block allocator for ext4 Andrew Morton
2008-01-23 23:20 ` Andreas Dilger
2008-01-24 7:56 ` Aneesh Kumar K.V
2008-01-24 9:04 ` Aneesh Kumar K.V
2008-01-24 14:53 ` Aneesh Kumar K.V
2008-01-23 22:07 ` [PATCH 36/49] ext4: Add EXT4_IOC_MIGRATE ioctl Andrew Morton
2008-01-24 5:55 ` Aneesh Kumar K.V
2008-01-26 4:15 ` Theodore Tso
2008-01-26 8:42 ` Aneesh Kumar K.V
2008-01-23 22:06 ` [PATCH 24/49] ext4: add block bitmap validation Andrew Morton
2008-01-26 13:26 ` Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080124052227.GA7902@skywalker \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@MIT.EDU \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox