All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: LKML <linux-kernel@vger.kernel.org>, linux-fsdevel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: question about buffer_busy check
Date: Tue, 23 Apr 2013 15:41:18 +0400	[thread overview]
Message-ID: <8738uh5va9.fsf@openvz.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]


Hi,
Can anyone please justify me the logic of fs/bufferc.c:buffer_busy()
How can we perform bit-wise operation for ->b_count and ->b_state?
 static inline int buffer_busy(struct buffer_head *bh)
 {
       return atomic_read(&bh->b_count) |
                (bh->b_state & ((1 << BH_Dirty) | (1 << BH_Lock)));
 }

I try to digg inside git/cvs history and it is appeared that 2.4 was
also implemented like this. At least it was so in 2000'th
http://lkml.indiana.edu/hypermail/linux/kernel/0006.0/0412.html
Also I've found similar complain
http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg24377.html
But seems nobody care about it. What's the point?
The only guess I have is that this is a miss typo  because buffer
is busy if some one hold an reference (bh->b_count !=0 )  ||
it is (dirty | locked). So following patch should fix 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-buffer-fix-miss-typo.patch --]
[-- Type: text/x-patch, Size: 698 bytes --]

>From dc45e525b647ed11f26781b80eed3894cc3ba325 Mon Sep 17 00:00:00 2001
From: Dmitry Monakhov <dmonakhov@openvz.org>
Date: Tue, 23 Apr 2013 15:24:24 +0400
Subject: [PATCH] buffer: fix miss typo


Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/buffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index b4dcb34..4ffa6c9 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3119,7 +3119,7 @@ EXPORT_SYMBOL(sync_dirty_buffer);
  */
 static inline int buffer_busy(struct buffer_head *bh)
 {
-	return atomic_read(&bh->b_count) |
+	return atomic_read(&bh->b_count) ||
 		(bh->b_state & ((1 << BH_Dirty) | (1 << BH_Lock)));
 }
 
-- 
1.7.1


             reply	other threads:[~2013-04-23 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 11:41 Dmitry Monakhov [this message]
2013-04-23 20:18 ` question about buffer_busy check Al Viro

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=8738uh5va9.fsf@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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.