[PATCH 09/25] make access() use mnt check

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <akpm@...>
Cc: <linux-kernel@...>, <hch@...>, Dave Hansen <haveblue@...>
Date: Thursday, September 20, 2007 - 3:53 pm

It is OK to let access() go without using a mnt_want/drop_write()
pair because it doesn't actually do writes to the filesystem,
and it is inherently racy anyway.  This is a rare case when it is
OK to use __mnt_is_readonly() directly.

Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 lxc-dave/fs/open.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff -puN fs/open.c~make-access-use-helper fs/open.c
--- lxc/fs/open.c~make-access-use-helper	2007-09-20 12:16:13.000000000 -0700
+++ lxc-dave/fs/open.c	2007-09-20 12:16:13.000000000 -0700
@@ -457,8 +457,17 @@ asmlinkage long sys_faccessat(int dfd, c
 	if(res || !(mode & S_IWOTH) ||
 	   special_file(nd.dentry->d_inode->i_mode))
 		goto out_path_release;
-
-	if(IS_RDONLY(nd.dentry->d_inode))
+	/*
+	 * This is a rare case where using __mnt_is_readonly()
+	 * is OK without a mnt_want/drop_write() pair.  Since
+	 * no actual write to the fs is performed here, we do
+	 * not need to telegraph to that to anyone.
+	 *
+	 * By doing this, we accept that this access is
+	 * inherently racy and know that the fs may change
+	 * state before we even see this result.
+	 */
+	if (__mnt_is_readonly(nd.mnt))
 		res = -EROFS;
 
 out_path_release:
_
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/25] Read-only bind mounts, Dave Hansen, (Thu Sep 20, 3:52 pm)
Re: [PATCH 24/25] r/o bind mounts: track number of mount wri..., Christoph Hellwig, (Mon Sep 24, 1:54 pm)
Re: [PATCH 24/25] r/o bind mounts: track number of mount wri..., Christoph Hellwig, (Mon Sep 24, 3:24 pm)
Re: [PATCH 24/25] r/o bind mounts: track number of mount wri..., Arjan van de Ven, (Mon Sep 24, 10:34 am)
[PATCH 25/25] honor r/w changes at do_remount() time, Dave Hansen, (Thu Sep 20, 3:53 pm)
[PATCH 23/25] do_rmdir(): elevate write count, Dave Hansen, (Thu Sep 20, 3:53 pm)
[PATCH 06/25] elevate write count open()'d files, Dave Hansen, (Thu Sep 20, 3:52 pm)
Re: [PATCH 06/25] elevate write count open()'d files, Andrew Morton, (Wed Nov 28, 4:41 am)
Re: [PATCH 06/25] elevate write count open()'d files, Dave Hansen, (Wed Nov 28, 1:33 pm)
[PATCH 19/25] elevate write count for do_utimes(), Dave Hansen, (Thu Sep 20, 3:53 pm)
[PATCH 02/25] rearrange may_open() to be r/o friendly, Dave Hansen, (Thu Sep 20, 3:52 pm)
[RFC] detect missed mnt_want_write() calls, Dave Hansen, (Tue Sep 25, 9:34 pm)
[PATCH 09/25] make access() use mnt check, Dave Hansen, (Thu Sep 20, 3:53 pm)
[PATCH 05/25] r/o bind mounts: stub functions, Dave Hansen, (Thu Sep 20, 3:52 pm)
[PATCH 04/25] create cleanup helper svc_msnfs(), Dave Hansen, (Thu Sep 20, 3:52 pm)
[PATCH 03/25] give may_open() a local 'mnt' variable, Dave Hansen, (Thu Sep 20, 3:52 pm)
Re: [PATCH 03/25] give may_open() a local 'mnt' variable, Christoph Hellwig, (Thu Sep 20, 3:57 pm)