From: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: Linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] loop cleanup in fs/namespace.c
Date: Tue, 13 Nov 2007 05:59:12 +0300 [thread overview]
Message-ID: <47391300.7070604@gmail.com> (raw)
Hi Alexander,
Although the following non-idiomatic and quite cumbersome C language construct
label:
if (condition) {
// DO HARD WORK
goto label;
}
is equivalent to a simple while loop
while (condition) {
// DO HARD WORK
}
it was the "label-if-goto label" approach chosen to implement the loop in the mntput_no_expire() routine located in `fs/namespace.c'.
The patch enclosed to this message changes the goto-based loop to a while-based one, not only saving us two lines of code, but also making the implementation idiomatic and thus more readable.
Thanks,
Dmitri
Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
--
diff --git a/fs/namespace.c b/fs/namespace.c
index 0608388..6a0cee1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -278,8 +278,7 @@ static inline void __mntput(struct vfsmo
void mntput_no_expire(struct vfsmount *mnt)
{
-repeat:
- if (atomic_dec_and_lock(&mnt->mnt_count, &vfsmount_lock)) {
+ while (atomic_dec_and_lock(&mnt->mnt_count, &vfsmount_lock)) {
if (likely(!mnt->mnt_pinned)) {
spin_unlock(&vfsmount_lock);
__mntput(mnt);
@@ -290,7 +289,6 @@ repeat:
spin_unlock(&vfsmount_lock);
acct_auto_close_mnt(mnt);
security_sb_umount_close(mnt);
- goto repeat;
}
}
reply other threads:[~2007-11-13 2:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=47391300.7070604@gmail.com \
--to=dmitri.vorobiev@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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