Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1364520 > unrolled thread

[PATCH] fs/vfs: improve __mnt_is_readonly

Started byYaowei Bai <baiyaowei@cmss.chinamobile.com>
First post2016-03-25 03:10 +0100
Last post2016-03-30 09:40 +0200
Articles 6 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fs/vfs: improve __mnt_is_readonly Yaowei Bai <baiyaowei@cmss.chinamobile.com> - 2016-03-25 03:10 +0100
    Re: [PATCH] fs/vfs: improve __mnt_is_readonly Al Viro <viro@ZenIV.linux.org.uk> - 2016-03-26 01:50 +0100
      Re: [PATCH] fs/vfs: improve __mnt_is_readonly Yaowei Bai <baiyaowei@cmss.chinamobile.com> - 2016-03-29 08:40 +0200
        Re: [PATCH] fs/vfs: improve __mnt_is_readonly Richard Weinberger <richard.weinberger@gmail.com> - 2016-03-29 11:50 +0200
          Re: [PATCH] fs/vfs: improve __mnt_is_readonly Yaowei Bai <baiyaowei@cmss.chinamobile.com> - 2016-03-30 03:30 +0200
            Re: [PATCH] fs/vfs: improve __mnt_is_readonly Richard Weinberger <richard@nod.at> - 2016-03-30 09:40 +0200

#1364520 — [PATCH] fs/vfs: improve __mnt_is_readonly

FromYaowei Bai <baiyaowei@cmss.chinamobile.com>
Date2016-03-25 03:10 +0100
Subject[PATCH] fs/vfs: improve __mnt_is_readonly
Message-ID<rgpmi-391-3@gated-at.bofh.it>
This patch refactors __mnt_is_readonly and makes it return bool to
improve readability due to this particular function only using either
one or zero as its return value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
---
 fs/namespace.c        | 9 +++------
 include/linux/mount.h | 2 +-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 4fb1691..4f2facd 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -271,13 +271,10 @@ out_free_cache:
  * mnt_want/drop_write() will _keep_ the filesystem
  * r/w.
  */
-int __mnt_is_readonly(struct vfsmount *mnt)
+bool __mnt_is_readonly(struct vfsmount *mnt)
 {
-	if (mnt->mnt_flags & MNT_READONLY)
-		return 1;
-	if (mnt->mnt_sb->s_flags & MS_RDONLY)
-		return 1;
-	return 0;
+	return mnt->mnt_flags & MNT_READONLY ||
+			mnt->mnt_sb->s_flags & MS_RDONLY;
 }
 EXPORT_SYMBOL_GPL(__mnt_is_readonly);
 
diff --git a/include/linux/mount.h b/include/linux/mount.h
index f822c3c..c143e15 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -80,7 +80,7 @@ extern void mnt_drop_write_file(struct file *file);
 extern void mntput(struct vfsmount *mnt);
 extern struct vfsmount *mntget(struct vfsmount *mnt);
 extern struct vfsmount *mnt_clone_internal(struct path *path);
-extern int __mnt_is_readonly(struct vfsmount *mnt);
+extern bool __mnt_is_readonly(struct vfsmount *mnt);
 
 struct path;
 extern struct vfsmount *clone_private_mount(struct path *path);
-- 
1.9.1

[toc] | [next] | [standalone]


#1364887

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-03-26 01:50 +0100
Message-ID<rgKAq-1me-1@gated-at.bofh.it>
In reply to#1364520
On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> This patch refactors __mnt_is_readonly and makes it return bool to
> improve readability due to this particular function only using either
> one or zero as its return value.

Improve in which way, if I may ask?

[toc] | [prev] | [next] | [standalone]


#1365901

FromYaowei Bai <baiyaowei@cmss.chinamobile.com>
Date2016-03-29 08:40 +0200
Message-ID<rhVtM-2bq-11@gated-at.bofh.it>
In reply to#1364887
On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> > This patch refactors __mnt_is_readonly and makes it return bool to
> > improve readability due to this particular function only using either
> > one or zero as its return value.
> 
> Improve in which way, if I may ask?

A boolean return value can be more matchable with function's name and
more suitable as this function only returns 0/1.

[toc] | [prev] | [next] | [standalone]


#1366075

FromRichard Weinberger <richard.weinberger@gmail.com>
Date2016-03-29 11:50 +0200
Message-ID<rhYrD-46p-1@gated-at.bofh.it>
In reply to#1365901
On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
<baiyaowei@cmss.chinamobile.com> wrote:
> On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
>> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
>> > This patch refactors __mnt_is_readonly and makes it return bool to
>> > improve readability due to this particular function only using either
>> > one or zero as its return value.
>>
>> Improve in which way, if I may ask?
>
> A boolean return value can be more matchable with function's name and
> more suitable as this function only returns 0/1.

Please also think of the arguments made on linux-mtd[1].
Hopping from one subsystem to another trying to sneak patches
in is not the best idea... :-)

[1]: http://lists.infradead.org/pipermail/linux-mtd/2016-March/066296.html

-- 
Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1366844

FromYaowei Bai <baiyaowei@cmss.chinamobile.com>
Date2016-03-30 03:30 +0200
Message-ID<rid7k-6mj-5@gated-at.bofh.it>
In reply to#1366075
On Tue, Mar 29, 2016 at 11:43:21AM +0200, Richard Weinberger wrote:
> On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
> <baiyaowei@cmss.chinamobile.com> wrote:
> > On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
> >> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> >> > This patch refactors __mnt_is_readonly and makes it return bool to
> >> > improve readability due to this particular function only using either
> >> > one or zero as its return value.
> >>
> >> Improve in which way, if I may ask?
> >
> > A boolean return value can be more matchable with function's name and
> > more suitable as this function only returns 0/1.
> 
> Please also think of the arguments made on linux-mtd[1].
> Hopping from one subsystem to another trying to sneak patches
> in is not the best idea... :-)

Acturally, this patch was sent before the mtd ones and all of them were sent
in one shot. You're really thinking too much.:-)

> 
> [1]: http://lists.infradead.org/pipermail/linux-mtd/2016-March/066296.html
> 
> -- 
> Thanks,
> //richard

[toc] | [prev] | [next] | [standalone]


#1366958

FromRichard Weinberger <richard@nod.at>
Date2016-03-30 09:40 +0200
Message-ID<riiTn-24i-1@gated-at.bofh.it>
In reply to#1366844
Am 30.03.2016 um 03:23 schrieb Yaowei Bai:
> On Tue, Mar 29, 2016 at 11:43:21AM +0200, Richard Weinberger wrote:
>> On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
>> <baiyaowei@cmss.chinamobile.com> wrote:
>>> On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
>>>> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
>>>>> This patch refactors __mnt_is_readonly and makes it return bool to
>>>>> improve readability due to this particular function only using either
>>>>> one or zero as its return value.
>>>>
>>>> Improve in which way, if I may ask?
>>>
>>> A boolean return value can be more matchable with function's name and
>>> more suitable as this function only returns 0/1.
>>
>> Please also think of the arguments made on linux-mtd[1].
>> Hopping from one subsystem to another trying to sneak patches
>> in is not the best idea... :-)
> 
> Acturally, this patch was sent before the mtd ones and all of them were sent
> in one shot. You're really thinking too much.:-)

I was referring to your answer not to your patch.

Thanks,
//richard

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web