All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: cmm@us.ibm.com, torvalds@linux-foundation.org,
	a.p.zijlstra@chello.nl, akpm@linux-foundation.org,
	adilger@clusterfs.com,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH 1/4] Add buffer head related helper functions
Date: Thu, 15 Nov 2007 17:40:43 +0530	[thread overview]
Message-ID: <1195128646-15143-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1195128646-15143-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

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>
---
 include/linux/buffer_head.h |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index da0d83f..82cc9ef 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -327,6 +327,35 @@ static inline void lock_buffer(struct buffer_head *bh)
 
 extern int __set_page_dirty_buffers(struct page *page);
 
+/* Return true if the buffer is up-to-date.
+ * Return false, with the buffer locked, if not.
+ */
+static inline 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;
+}
+/*
+ * Submit a locked buffer for reading,
+ * return a negative error and release
+ * the buffer if failed.
+ */
+static inline int bh_submit_read(struct buffer_head *bh)
+{
+	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;
+	brelse(bh);
+	return -EIO;
+}
 #else /* CONFIG_BLOCK */
 
 static inline void buffer_init(void) {}
-- 
1.5.3.5.652.gf192c-dirty

  reply	other threads:[~2007-11-15 12:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15 12:10 ext2/3/4 block bitmap validation patches Aneesh Kumar K.V
2007-11-15 12:10 ` Aneesh Kumar K.V [this message]
2007-11-15 12:10   ` [PATCH 2/4] ext2: add block bitmap validation Aneesh Kumar K.V
2007-11-15 12:10     ` [PATCH 3/4] ext3: " Aneesh Kumar K.V
2007-11-15 12:10       ` [PATCH 4/4] ext4: " Aneesh Kumar K.V
2007-11-16 21:33   ` [PATCH 1/4] Add buffer head related helper functions Andrew Morton

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=1195128646-15143-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adilger@clusterfs.com \
    --cc=akpm@linux-foundation.org \
    --cc=cmm@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.