Bind Mount Extensions 0.04 (linux-2.6.4)
Subsystems (22)
PATCH 1/1 Bind Mount Extensions 0.04 (linux-2.6.4)
;
; Bind Mount Extensions
;
; this patch adds some functionality to the --bind ; type of vfs mounts.
;
; (C) 2003-2004 Herbert Pötzl <[email protected]> ;
; Changelog:
;
; 0.01 - readonly bind mounts ; 0.02 - added ro truncate handling ; - added ro (f)chown, (f)chmod handling ; 0.03 - added ro utime(s) handling ; - added ro access and *_ioctl ; 0.04 - added noatime and nodiratime ; - made autofs4 update_atime uncond
;
; this patch is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ;
; this patch is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details.
;
drivers/char/random.c +1 -1
@@ -1641,7 +1641,7 @@ random_read(struct file * file, char * b* If we gave the user some bytes, update the access time. */ if (count !=0 ) { -update_atime (file->f_dentry->d_inode); +update_atime (file->f_dentry->d_inode, file->f_vfsmnt); }return (count ? count : retval);
fs/autofs4/root.c +2 -1
@@ -61,7 +61,8 @@ static void autofs4_update_usage(structstruct autofs_info *ino =autofs4_dentry_ino (dentry);if (ino) { -update_atime (dentry->d_inode); +/* Al Viro said: unconditional */ +update_atime (dentry->d_inode,0 ); ino->last_used = jiffies; } }
fs/bfs/dir.c +1 -1
@@ -65,7 +65,7 @@ static int bfs_readdir(struct file * f,brelse (bh); } -update_atime (dir); +update_atime (dir, f->f_vfsmnt);unlock_kernel ();return 0 ; }
fs/ext2/dir.c +1 -1
@@ -310,7 +310,7 @@ ext2_readdir (struct file * filp, void * done: filp->f_pos = (n <<PAGE_CACHE_SHIFT ) | offset; filp->f_version = inode->i_version; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);return 0 ; }
fs/ext2/ioctl.c +3 -2
@@ -10,6 +10,7 @@#include "ext2.h" #include <linux/time.h> #include <linux/sched.h> +#include <linux/mount.h> #include <asm/current.h> #include <asm/uaccess.h>
@@ -29,7 +30,7 @@ int ext2_ioctl (struct inode * inode, stcase EXT2_IOC_SETFLAGS : {unsigned int oldflags; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -68,7 +69,7 @@ int ext2_ioctl (struct inode * inode, stcase EXT2_IOC_SETVERSION :if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if (get_user (inode->i_generation, (int *) arg))return -EFAULT ;
fs/ext3/dir.c +2 -2
@@ -224,7 +224,7 @@ revalidate: offset =0 ;brelse (bh); } -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); out:return ret; }
@@ -506,7 +506,7 @@ static int ext3_dx_readdir(struct file * } finished: info->last_pos = filp->f_pos; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);return 0 ; }
fs/ext3/ioctl.c +3 -2
@@ -12,6 +12,7 @@#include <linux/ext3_fs.h> #include <linux/ext3_jbd.h> #include <linux/time.h> +#include <linux/mount.h> #include <asm/uaccess.h>
@@ -34,7 +35,7 @@ int ext3_ioctl (struct inode * inode, stunsigned int oldflags;unsigned int jflag; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -110,7 +111,7 @@ flags_err:if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if (get_user (generation, (int *) arg))return -EFAULT ;
fs/hugetlbfs/inode.c +1 -1
@@ -62,7 +62,7 @@ static int hugetlbfs_file_mmap(struct fi vma_len = (loff_t)(vma->vm_end - vma->vm_start);down (&inode->i_sem); -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_flags |=VM_HUGETLB |VM_RESERVED ; vma->vm_ops = &hugetlb_vm_ops; ret =hugetlb_prefault (mapping, vma);
fs/inode.c +6 -4
@@ -20,6 +20,7 @@#include <linux/security.h> #include <linux/pagemap.h> #include <linux/cdev.h> +#include <linux/mount.h> /* * This is needed for the following functions:
@@ -1141,15 +1142,16 @@ static int inode_times_differ(struct ino* This function automatically handles read only file systems and media, * as well as the "noatime" flag and inode specific "noatime" markers. */ -void update_atime (struct inode *inode) +void update_atime (struct inode *inode,struct vfsmount *mnt) {struct timespec now; -if (IS_NOATIME (inode)) +if (IS_NOATIME (inode) ||MNT_IS_NOATIME (mnt))return ; -if (IS_NODIRATIME (inode) &&S_ISDIR (inode->i_mode)) +if (S_ISDIR (inode->i_mode) && + (IS_NODIRATIME (inode) ||MNT_IS_NODIRATIME (mnt)))return ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (mnt))return ; now =current_kernel_time ();
fs/libfs.c +1 -1
@@ -155,7 +155,7 @@ int dcache_readdir(struct file * filp, v }spin_unlock (&dcache_lock); } -update_atime (dentry->d_inode); +update_atime (dentry->d_inode, filp->f_vfsmnt);return 0 ; }
fs/minix/dir.c +1 -1
@@ -127,7 +127,7 @@ static int minix_readdir(struct file * f done: filp->f_pos = (n <<PAGE_CACHE_SHIFT ) | offset; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);unlock_kernel ();return 0 ; }
fs/namei.c +48 -10
127 lines not on this page · raw message
fs/namespace.c +13 -3
@@ -229,7 +229,8 @@ static int show_vfsmnt(struct seq_file *seq_path (m, mnt, mnt->mnt_root," \t\n\\" );seq_putc (m,' ' );mangle (m, mnt->mnt_sb->s_type->name); -seq_puts (m, mnt->mnt_sb->s_flags &MS_RDONLY ?" ro" :" rw" ); +seq_puts (m, (MNT_IS_RDONLY (mnt) || + (mnt->mnt_sb->s_flags &MS_RDONLY )) ?" ro" :" rw" );for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {if (mnt->mnt_sb->s_flags & fs_infop->flag)seq_puts (m, fs_infop->str);
@@ -522,11 +523,13 @@ out_unlock:/* * do loopback mount. */ -static int do_loopback (struct nameidata *nd,char *old_name,int recurse) +static int do_loopback (struct nameidata *nd,char *old_name,unsigned long flags,int mnt_flags) {struct nameidata old_nd;struct vfsmount *mnt =NULL ; +int recurse = flags &MS_REC ;int err =mount_is_safe (nd); +if (err)return err;if (!old_name || !*old_name)
@@ -553,6 +556,7 @@ static int do_loopback(struct nameidataspin_unlock (&vfsmount_lock); }else mntput (mnt); + mnt->mnt_flags = mnt_flags; }up_write (¤t->namespace->sem);
@@ -759,12 +763,18 @@ long do_mount(char * dev_name, char * di ((char *)data_page)[PAGE_SIZE -1 ] =0 ;/* Separate the per-mountpoint flags */ +if (flags &MS_RDONLY ) + mnt_flags |=MNT_RDONLY ;if (flags &MS_NOSUID ) mnt_flags |=MNT_NOSUID ;if (flags &MS_NODEV ) mnt_flags |=MNT_NODEV ;if (flags &MS_NOEXEC ) mnt_flags |=MNT_NOEXEC ; +if (flags &MS_NOATIME ) + mnt_flags |=MNT_NOATIME ; +if (flags &MS_NODIRATIME ) + mnt_flags |=MNT_NODIRATIME ; flags &= ~(MS_NOSUID |MS_NOEXEC |MS_NODEV );/* ... and get the mountpoint */
@@ -780,7 +790,7 @@ long do_mount(char * dev_name, char * di retval =do_remount (&nd, flags & ~MS_REMOUNT , mnt_flags, data_page); else if (flags & MS_BIND) - retval =do_loopback (&nd, dev_name, flags &MS_REC ); + retval =do_loopback (&nd, dev_name, flags, mnt_flags); else if (flags & MS_MOVE) retval =do_move_mount (&nd, dev_name); else
fs/nfsd/vfs.c +1 -1
@@ -1143,7 +1143,7 @@ nfsd_readlink(struct svc_rqst *rqstp, stif (!inode->i_op || !inode->i_op->readlink) goto out; -update_atime (inode); +update_atime (inode, fhp->fh_export->ex_mnt);/* N.B. Why does this call need a get_fs()?? * Remove the set_fs and watch the fireworks:-) --okir */
fs/open.c +13 -12
@@ -226,7 +226,7 @@ static inline long do_sys_truncate(const goto dput_and_out; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (nd.mnt)) goto dput_and_out; error = -EPERM ;
@@ -350,7 +350,7 @@ asmlinkage long sys_utime(char __user * inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (nd.mnt)) goto dput_and_out;/* Don't worry, the checks are done in inode_change_ok() */
@@ -407,7 +407,7 @@ long do_utimes(char __user * filename, s inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (nd.mnt)) goto dput_and_out;/* Don't worry, the checks are done in inode_change_ok() */
@@ -489,8 +489,9 @@ asmlinkage long sys_access(const char __if (!res) { res =permission (nd.dentry->d_inode, mode, &nd);/* SuS v2 requires we report a read only fs too */ -if (!res && (mode &S_IWOTH ) &&IS_RDONLY (nd.dentry->d_inode) - && !special_file (nd.dentry->d_inode->i_mode)) +if (!res && (mode &S_IWOTH ) + && !special_file (nd.dentry->d_inode->i_mode) + && (IS_RDONLY (nd.dentry->d_inode) ||MNT_IS_RDONLY (nd.mnt))) res = -EROFS ;path_release (&nd); }
@@ -595,7 +596,7 @@ asmlinkage long sys_fchmod(unsigned int inode = dentry->d_inode; err = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (file->f_vfsmnt)) goto out_putf; err = -EPERM ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))
@@ -627,7 +628,7 @@ asmlinkage long sys_chmod(const char __u inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (nd.mnt)) goto dput_and_out; error = -EPERM ;
@@ -648,7 +649,7 @@ out:return error; } -static int chown_common (struct dentry * dentry,uid_t user,gid_t group) +static int chown_common (struct vfsmount *mnt,struct dentry * dentry,uid_t user,gid_t group) {struct inode * inode;int error;
@@ -660,7 +661,7 @@ static int chown_common(struct dentry * goto out; } error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (mnt)) goto out; error = -EPERM ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))
@@ -690,7 +691,7 @@ asmlinkage long sys_chown(const char __u error =user_path_walk (filename, &nd);if (!error) { - error =chown_common (nd.dentry, user, group); + error =chown_common (nd.mnt, nd.dentry, user, group);path_release (&nd); }return error;
@@ -703,7 +704,7 @@ asmlinkage long sys_lchown(const char __ error =user_path_walk_link (filename, &nd);if (!error) { - error =chown_common (nd.dentry, user, group); + error =chown_common (nd.mnt, nd.dentry, user, group);path_release (&nd); }return error;
@@ -717,7 +718,7 @@ asmlinkage long sys_fchown(unsigned int file =fget (fd);if (file) { - error =chown_common (file->f_dentry, user, group); + error =chown_common (file->f_vfsmnt, file->f_dentry, user, group);fput (file); }return error;
fs/pipe.c +1 -1
@@ -165,7 +165,7 @@ pipe_readv(struct file *filp, const strukill_fasync (PIPE_FASYNC_WRITERS (*inode),SIGIO ,POLL_OUT ); }if (ret >0 ) -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);return ret; }
fs/qnx4/dir.c +1 -1
@@ -76,7 +76,7 @@ static int qnx4_readdir(struct file *fil }brelse (bh); } -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); out:unlock_kernel ();
fs/reiserfs/dir.c +1 -1
@@ -186,7 +186,7 @@ static int reiserfs_readdir (struct file filp->f_pos = next_pos;pathrelse (&path_to_entry);reiserfs_check_path (&path_to_entry) ; -update_atime (inode) ; +update_atime (inode, filp->f_vfsmnt) ; out:reiserfs_write_unlock (inode->i_sb);return ret;
fs/reiserfs/ioctl.c +3 -2
@@ -5,6 +5,7 @@#include <linux/fs.h> #include <linux/reiserfs_fs.h> #include <linux/time.h> +#include <linux/mount.h> #include <asm/uaccess.h> #include <linux/pagemap.h> #include <linux/smp_lock.h>
@@ -38,7 +39,7 @@ int reiserfs_ioctl (struct inode * inodei_attrs_to_sd_attrs ( inode, (__u16 * ) &flags );return put_user (flags, (int *) arg);case REISERFS_IOC_SETFLAGS : { -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -70,7 +71,7 @@ int reiserfs_ioctl (struct inode * inodecase REISERFS_IOC_SETVERSION :if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode) ||MNT_IS_RDONLY (filp->f_vfsmnt))return -EROFS ;if (get_user (inode->i_generation, (int *) arg))return -EFAULT ;
fs/stat.c +1 -1
@@ -272,7 +272,7 @@ asmlinkage long sys_readlink(const charif (inode->i_op && inode->i_op->readlink) { error =security_inode_readlink (nd.dentry);if (!error) { -update_atime (inode); +update_atime (inode, nd.mnt); error = inode->i_op->readlink (nd.dentry, buf, bufsiz); } }
fs/sysv/dir.c +1 -1
@@ -116,7 +116,7 @@ static int sysv_readdir(struct file * fi done: filp->f_pos = (n <<PAGE_CACHE_SHIFT ) | offset; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);unlock_kernel ();return 0 ; }
fs/udf/dir.c +1 -1
@@ -98,7 +98,7 @@ int udf_readdir(struct file *filp, void } result =do_udf_readdir (dir, filp, filldir, dirent); -update_atime (dir); +update_atime (dir, filp->f_vfsmnt);unlock_kernel ();return result; }
fs/ufs/dir.c +1 -1
@@ -166,7 +166,7 @@ revalidate: offset =0 ;brelse (bh); } -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);unlock_kernel ();return 0 ; }
include/linux/fs.h +1 -1
@@ -211,7 +211,7 @@ extern int leases_enable, dir_notify_ena#include <asm/byteorder.h> /* Used to be a macro which just called the function, now just a function */ -extern void update_atime (struct inode *); +extern void update_atime (struct inode *,struct vfsmount *);extern void inode_init (unsigned long );extern void mnt_init (unsigned long );
include/linux/mount.h +11 -3
@@ -14,9 +14,12 @@#include <linux/list.h> -#define MNT_NOSUID 1 -#define MNT_NODEV 2 -#define MNT_NOEXEC 4 +#define MNT_RDONLY 1 +#define MNT_NOSUID 2 +#define MNT_NODEV 4 +#define MNT_NOEXEC 8 +#define MNT_NOATIME 1024 +#define MNT_NODIRATIME 2048struct vfsmount {
@@ -33,6 +36,11 @@ struct vfsmountstruct list_head mnt_list; }; +/* remove (m) with fixmes */ +#define MNT_IS_RDONLY (m) ((m) && ((m)->mnt_flags & MNT_RDONLY)) +#define MNT_IS_NOATIME (m) ((m) && ((m)->mnt_flags & MNT_NOATIME)) +#define MNT_IS_NODIRATIME (m) ((m) && ((m)->mnt_flags & MNT_NODIRATIME)) +static inline struct vfsmount *mntget (struct vfsmount *mnt) {if (mnt)
ipc/shm.c +1 -1
@@ -149,7 +149,7 @@ static void shm_close (struct vm_area_ststatic int shm_mmap (struct file * file,struct vm_area_struct * vma) { -update_atime (file->f_dentry->d_inode); +update_atime (file->f_dentry->d_inode, file->f_vfsmnt); vma->vm_ops = &shm_vm_ops;shm_inc (file->f_dentry->d_inode->i_ino);return 0 ;
mm/filemap.c +3 -3
@@ -725,7 +725,7 @@ no_cached_page: *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset;if (cached_page)page_cache_release (cached_page); -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); }EXPORT_SYMBOL (do_generic_mapping_read);
@@ -820,7 +820,7 @@ __generic_file_aio_read(struct kiocb *ioif (retval >0 ) *ppos = pos + retval; } -update_atime (filp->f_dentry->d_inode); +update_atime (filp->f_dentry->d_inode, filp->f_vfsmnt); goto out; }
@@ -1357,7 +1357,7 @@ int generic_file_mmap(struct file * fileif (!mapping->a_ops->readpage)return -ENOEXEC ; -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_ops = &generic_file_vm_ops;return 0 ; }
mm/shmem.c +2 -2
@@ -1067,7 +1067,7 @@ static int shmem_mmap(struct file *file, ops = &shmem_vm_ops;if (!S_ISREG (inode->i_mode))return -EACCES ; -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_ops = ops;return 0 ; }
@@ -1363,7 +1363,7 @@ static void do_shmem_file_read(struct fi } *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); }static ssize_t shmem_file_read (struct file *filp,char __user *buf,size_t count,loff_t *ppos)
net/unix/af_unix.c +2 -2
@@ -691,7 +691,7 @@ static struct sock *unix_find_other(stru goto put_fail;if (u->sk_type == type) -update_atime (nd.dentry->d_inode); +update_atime (nd.dentry->d_inode, nd.mnt);path_release (&nd);
@@ -707,7 +707,7 @@ static struct sock *unix_find_other(strustruct dentry *dentry; dentry =unix_sk (u)->dentry;if (dentry) -update_atime (dentry->d_inode); +update_atime (dentry->d_inode, nd.mnt); }else goto fail; }
Quoted 3 lines · Herbert Poetzl
; this patch adds some functionality to the --bind ; type of vfs mounts.
This won't apply any more. We very recently changed a large number of filesystems to not call update_atime() from within their readdir functions. That operation was hoisted up to vfs_readdir().
Also, rather than adding MNT_IS_RDONLY() and having to remember to check both the inode and the mount all over the kernel it would be better to change IS_RDONLY() to take two arguments - the inode and the vfsmnt. That way we won't miss places, and unconverted code simpy won't compile, thus drawing attention to itself. I don't know if this is feasible, but please consider it.
Quoted 8 lines · Andrew Morton
Quoted 3 lines · Herbert Poetzl
; this patch adds some functionality to the --bind ; type of vfs mounts.
This won't apply any more. We very recently changed a large number of filesystems to not call
update_atime()from within their readdir functions. That operation was hoisted up tovfs_readdir().
good decision, very recently probably means in the bk repository, is there any link where I could download those changes?
Quoted 6 lines
Also, rather than adding
MNT_IS_RDONLY()and having to remember to check both the inode and the mount all over the kernel it would be better to changeIS_RDONLY()to take two arguments - the inode and the vfsmnt. That way we won't miss places, and unconverted code simpy won't compile, thus drawing attention to itself. I don't know if this is feasible, but please consider it.
I don't have a problem with that, and it sounds good to me so far, so I'll have a look at it, and will update the patch accordingly ...
thanks for the response,
Herbert
Quoted 7 lines · Herbert Poetzl
Quoted 5 lines · Andrew Morton
Quoted 3 lines · Herbert Poetzl
; this patch adds some functionality to the --bind ; type of vfs mounts.
Quoted 6 lines
Quoted 3 lines
This won't apply any more. We very recently changed a large number of filesystems to not call
update_atime()from within their readdir functions. That operation was hoisted up tovfs_readdir().good decision, very recently probably means in the bk repository, is there any link where I could download those changes?
The latest diff against the most-recently-release kernel is always at
http://www.kernel.org/pub/linux/kernel/v2.5/testing/cset/
the topmost link.
Quoted 10 lines
Quoted 6 lines
Also, rather than adding
MNT_IS_RDONLY()and having to remember to check both the inode and the mount all over the kernel it would be better to changeIS_RDONLY()to take two arguments - the inode and the vfsmnt. That way we won't miss places, and unconverted code simpy won't compile, thus drawing attention to itself. I don't know if this is feasible, but please consider it.I don't have a problem with that, and it sounds good to me so far, so I'll have a look at it, and will update the patch accordingly ...
Thanks.
Quoted 7 lines · Andrew Morton
Quoted 6 lines · Herbert Poetzl
Quoted 5 lines · Andrew Morton
This won't apply any more. We very recently changed a large number of filesystems to not call
update_atime()from within their readdir functions.
That operation was hoisted up tovfs_readdir().
okay, patches do reflect this change now ...
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Also, rather than adding
MNT_IS_RDONLY()and having to remember to check both the inode and the mount all over the kernel it would be better to changeIS_RDONLY()to take two arguments - the inode and the vfsmnt. That way we won't miss places, and unconverted code simpy won't compile, thus drawing attention to itself. I don't know if this is feasible, but please consider it.
I decided to split this up into five parts, a simple base patch, a patch doing the noatime stuff, and three patches for the IS_RDONLY changes ...
bme0.04.1-ro1 ... are the completely resolved ones bme0.04.1-ro2 ... acl stuff, needs checking for nd bme0.04.1-ro3 ... unresolved/legacy
currently I do not know where to get the vfsmnt for the cases in bme0.04.1-ro3, so they use the legacy define IS_RDONLY_INODE() for their checks ...
I hope this is what you had in mind, but anyways, let me know how to proceed ...
best,
Herbert
PS: basic functionality has been verified.
http://www.13thfloor.at/patches/patch-2.6.4-20040314_2308-bme0.04.1.diff
http://www.13thfloor.at/patches/patch-2.6.4-20040314_2308-bme0.04.1-atime.diff
http://www.13thfloor.at/patches/patch-2.6.4-20040314_2308-bme0.04.1-ro1.diff
http://www.13thfloor.at/patches/patch-2.6.4-20040314_2308-bme0.04.1-ro2.diff
http://www.13thfloor.at/patches/patch-2.6.4-20040314_2308-bme0.04.1-ro3.diff
PATCH 1/1 Bind Mount Extensions 0.04.1 1/5
In reply to Andrew Morton;
; Bind Mount Extensions
;
; this patch adds some functionality to the --bind ; type of vfs mounts.
;
; (C) 2003-2004 Herbert Pötzl <[email protected]> ;
; Changelog:
;
; 0.01 - readonly bind mounts ; 0.02 - added ro truncate handling ; - added ro (f)chown, (f)chmod handling ; 0.03 - added ro utime(s) handling ; - added ro access and *_ioctl ; 0.04 - added noatime and nodiratime ; - made autofs4 update_atime uncond
;
; 0.04.1 IS_RDONLY extended by vfsmnt
; - IS_RDONLY_INODE() added for legacy
; - update_atime() updated (20040314_2308)
;
; this patch is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ;
; this patch is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details.
;
fs/namespace.c +13 -3
@@ -229,7 +229,8 @@ static int show_vfsmnt(struct seq_file *seq_path (m, mnt, mnt->mnt_root," \t\n\\" );seq_putc (m,' ' );mangle (m, mnt->mnt_sb->s_type->name); -seq_puts (m, mnt->mnt_sb->s_flags &MS_RDONLY ?" ro" :" rw" ); +seq_puts (m, (MNT_IS_RDONLY (mnt) || + (mnt->mnt_sb->s_flags &MS_RDONLY )) ?" ro" :" rw" );for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {if (mnt->mnt_sb->s_flags & fs_infop->flag)seq_puts (m, fs_infop->str);
@@ -522,11 +523,13 @@ out_unlock:/* * do loopback mount. */ -static int do_loopback (struct nameidata *nd,char *old_name,int recurse) +static int do_loopback (struct nameidata *nd,char *old_name,unsigned long flags,int mnt_flags) {struct nameidata old_nd;struct vfsmount *mnt =NULL ; +int recurse = flags &MS_REC ;int err =mount_is_safe (nd); +if (err)return err;if (!old_name || !*old_name)
@@ -553,6 +556,7 @@ static int do_loopback(struct nameidataspin_unlock (&vfsmount_lock); }else mntput (mnt); + mnt->mnt_flags = mnt_flags; }up_write (¤t->namespace->sem);
@@ -759,12 +763,18 @@ long do_mount(char * dev_name, char * di ((char *)data_page)[PAGE_SIZE -1 ] =0 ;/* Separate the per-mountpoint flags */ +if (flags &MS_RDONLY ) + mnt_flags |=MNT_RDONLY ;if (flags &MS_NOSUID ) mnt_flags |=MNT_NOSUID ;if (flags &MS_NODEV ) mnt_flags |=MNT_NODEV ;if (flags &MS_NOEXEC ) mnt_flags |=MNT_NOEXEC ; +if (flags &MS_NOATIME ) + mnt_flags |=MNT_NOATIME ; +if (flags &MS_NODIRATIME ) + mnt_flags |=MNT_NODIRATIME ; flags &= ~(MS_NOSUID |MS_NOEXEC |MS_NODEV );/* ... and get the mountpoint */
@@ -780,7 +790,7 @@ long do_mount(char * dev_name, char * di retval =do_remount (&nd, flags & ~MS_REMOUNT , mnt_flags, data_page); else if (flags & MS_BIND) - retval =do_loopback (&nd, dev_name, flags &MS_REC ); + retval =do_loopback (&nd, dev_name, flags, mnt_flags); else if (flags & MS_MOVE) retval =do_move_mount (&nd, dev_name); else
include/linux/mount.h +11 -3
@@ -14,9 +14,12 @@#include <linux/list.h> -#define MNT_NOSUID 1 -#define MNT_NODEV 2 -#define MNT_NOEXEC 4 +#define MNT_RDONLY 1 +#define MNT_NOSUID 2 +#define MNT_NODEV 4 +#define MNT_NOEXEC 8 +#define MNT_NOATIME 1024 +#define MNT_NODIRATIME 2048struct vfsmount {
@@ -33,6 +36,11 @@ struct vfsmountstruct list_head mnt_list; }; +/* remove (m) when done */ +#define MNT_IS_RDONLY (m) ((m) && ((m)->mnt_flags & MNT_RDONLY)) +#define MNT_IS_NOATIME (m) ((m) && ((m)->mnt_flags & MNT_NOATIME)) +#define MNT_IS_NODIRATIME (m) ((m) && ((m)->mnt_flags & MNT_NODIRATIME)) +static inline struct vfsmount *mntget (struct vfsmount *mnt) {if (mnt)
PATCH 1/1 Bind Mount Extensions 0.04.1 2/5
In reply to Andrew Mortoninclude/linux/fs.h +2 -2
@@ -214,7 +216,7 @@ extern int leases_enable, dir_notify_ena#include <asm/byteorder.h> /* Used to be a macro which just called the function, now just a function */ -extern void update_atime (struct inode *); +extern void update_atime (struct inode *,struct vfsmount *);extern void inode_init (unsigned long );extern void mnt_init (unsigned long );
@@ -1409,7 +1411,7 @@ extern void simple_release_fs(struct vfsextern int inode_change_ok (struct inode *,struct iattr *);extern int inode_setattr (struct inode *,struct iattr *); -extern void inode_update_time (struct inode *inode,int ctime_too); +extern void inode_update_time (struct inode *inode,int ctime_too,struct vfsmount *mount);static inline ino_t parent_ino (struct dentry *dentry) {
fs/inode.c +5 -4
@@ -1141,15 +1142,16 @@ static int inode_times_differ(struct ino* This function automatically handles read only file systems and media, * as well as the "noatime" flag and inode specific "noatime" markers. */ -void update_atime (struct inode *inode) +void update_atime (struct inode *inode,struct vfsmount *mnt) {struct timespec now; -if (IS_NOATIME (inode)) +if (IS_NOATIME (inode) ||MNT_IS_NOATIME (mnt))return ; -if (IS_NODIRATIME (inode) &&S_ISDIR (inode->i_mode)) +if (S_ISDIR (inode->i_mode) && + (IS_NODIRATIME (inode) ||MNT_IS_NODIRATIME (mnt)))return ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, mnt))return ; now =current_kernel_time ();
drivers/char/random.c +1 -1
@@ -1641,7 +1641,7 @@ random_read(struct file * file, char * b* If we gave the user some bytes, update the access time. */ if (count !=0 ) { -update_atime (file->f_dentry->d_inode); +update_atime (file->f_dentry->d_inode, file->f_vfsmnt); }return (count ? count : retval);
fs/autofs4/root.c +2 -1
@@ -61,7 +61,8 @@ static void autofs4_update_usage(structstruct autofs_info *ino =autofs4_dentry_ino (dentry);if (ino) { -update_atime (dentry->d_inode); +/* Al Viro said: unconditional */ +update_atime (dentry->d_inode,0 ); ino->last_used = jiffies; } }
fs/coda/dir.c +1 -1
@@ -512,7 +512,7 @@ int coda_readdir(struct file *coda_file, ret = -ENOENT ;if (!IS_DEADDIR (host_inode)) { ret = host_file->f_op->readdir (host_file, filldir, dirent); -update_atime (host_inode); +update_atime (host_inode, host_file->f_vfsmnt); } } out:
fs/hugetlbfs/inode.c +1 -1
@@ -62,7 +62,7 @@ static int hugetlbfs_file_mmap(struct fi vma_len = (loff_t)(vma->vm_end - vma->vm_start);down (&inode->i_sem); -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_flags |=VM_HUGETLB |VM_RESERVED ; vma->vm_ops = &hugetlb_vm_ops; ret =hugetlb_prefault (mapping, vma);
fs/namei.c +2 -2
@@ -412,7 +416,7 @@ static inline int do_follow_link(struct goto loop; current->link_count++; current->total_link_count++; -update_atime (dentry->d_inode); +update_atime (dentry->d_inode, nd->mnt); err = dentry->d_inode->i_op->follow_link (dentry, nd); current->link_count--;return err;
@@ -1368,7 +1390,7 @@ do_link: error =security_inode_follow_link (dentry, nd);if (error) goto exit_dput; -update_atime (dentry->d_inode); +update_atime (dentry->d_inode, nd->mnt); error = dentry->d_inode->i_op->follow_link (dentry, nd);dput (dentry);if (error)
fs/nfsd/vfs.c +1 -1
@@ -1143,7 +1143,7 @@ nfsd_readlink(struct svc_rqst *rqstp, stif (!inode->i_op || !inode->i_op->readlink) goto out; -update_atime (inode); +update_atime (inode, fhp->fh_export->ex_mnt);/* N.B. Why does this call need a get_fs()?? * Remove the set_fs and watch the fireworks:-) --okir */
fs/pipe.c +2 -2
@@ -165,7 +165,7 @@ pipe_readv(struct file *filp, const strukill_fasync (PIPE_FASYNC_WRITERS (*inode),SIGIO ,POLL_OUT ); }if (ret >0 ) -update_atime (inode); +update_atime (inode, filp->f_vfsmnt);return ret; }
@@ -263,7 +263,7 @@ pipe_writev(struct file *filp, const strkill_fasync (PIPE_FASYNC_READERS (*inode),SIGIO ,POLL_IN ); }if (ret >0 ) -inode_update_time (inode,1 );/* mtime and ctime */ +inode_update_time (inode,1 , filp->f_vfsmnt);/* mtime and ctime */ return ret; }
fs/readdir.c +1 -1
@@ -32,7 +32,7 @@ int vfs_readdir(struct file *file, filld res = -ENOENT ;if (!IS_DEADDIR (inode)) { res = file->f_op->readdir (file, buf, filler); -update_atime (inode); +update_atime (inode, file->f_vfsmnt); }up (&inode->i_sem); out:
fs/reiserfs/file.c +1 -1
@@ -1061,7 +1061,7 @@ ssize_t reiserfs_file_write( struct file goto out;remove_suid (file->f_dentry); -inode_update_time (inode,1 );/* Both mtime and ctime */ +inode_update_time (inode,1 , file->f_vfsmnt);/* Both mtime and ctime */ // Ok, we are done with all the checks.
fs/stat.c +1 -1
@@ -272,7 +272,7 @@ asmlinkage long sys_readlink(const charif (inode->i_op && inode->i_op->readlink) { error =security_inode_readlink (nd.dentry);if (!error) { -update_atime (inode); +update_atime (inode, nd.mnt); error = inode->i_op->readlink (nd.dentry, buf, bufsiz); } }
ipc/shm.c +1 -1
@@ -149,7 +149,7 @@ static void shm_close (struct vm_area_ststatic int shm_mmap (struct file * file,struct vm_area_struct * vma) { -update_atime (file->f_dentry->d_inode); +update_atime (file->f_dentry->d_inode, file->f_vfsmnt); vma->vm_ops = &shm_vm_ops;shm_inc (file->f_dentry->d_inode->i_ino);return 0 ;
mm/filemap.c +4 -4
@@ -725,7 +725,7 @@ no_cached_page: *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset;if (cached_page)page_cache_release (cached_page); -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); }EXPORT_SYMBOL (do_generic_mapping_read);
@@ -820,7 +820,7 @@ __generic_file_aio_read(struct kiocb *ioif (retval >0 ) *ppos = pos + retval; } -update_atime (filp->f_dentry->d_inode); +update_atime (filp->f_dentry->d_inode, filp->f_vfsmnt); goto out; }
@@ -1357,7 +1357,7 @@ int generic_file_mmap(struct file * fileif (!mapping->a_ops->readpage)return -ENOEXEC ; -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_ops = &generic_file_vm_ops;return 0 ; }
@@ -1783,7 +1783,7 @@ generic_file_aio_write_nolock(struct kio goto out;remove_suid (file->f_dentry); -inode_update_time (inode,1 ); +inode_update_time (inode,1 , file->f_vfsmnt);/* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ if (unlikely (file->f_flags &O_DIRECT )) {
mm/shmem.c +2 -2
@@ -1067,7 +1067,7 @@ static int shmem_mmap(struct file *file, ops = &shmem_vm_ops;if (!S_ISREG (inode->i_mode))return -EACCES ; -update_atime (inode); +update_atime (inode, file->f_vfsmnt); vma->vm_ops = ops;return 0 ; }
@@ -1363,7 +1363,7 @@ static void do_shmem_file_read(struct fi } *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset; -update_atime (inode); +update_atime (inode, filp->f_vfsmnt); }static ssize_t shmem_file_read (struct file *filp,char __user *buf,size_t count,loff_t *ppos)
net/unix/af_unix.c +2 -2
@@ -691,7 +691,7 @@ static struct sock *unix_find_other(stru goto put_fail;if (u->sk_type == type) -update_atime (nd.dentry->d_inode); +update_atime (nd.dentry->d_inode, nd.mnt);path_release (&nd);
@@ -707,7 +707,7 @@ static struct sock *unix_find_other(strustruct dentry *dentry; dentry =unix_sk (u)->dentry;if (dentry) -update_atime (dentry->d_inode); +update_atime (dentry->d_inode, nd.mnt); }else goto fail; }
Re: [PATCH] Bind Mount Extensions 0.04.1 2/5
fs/inode.c static int inode_times_differ(struct ino · line 1145
Quoted 2 lines · Herbert Poetzl
fs/inode.c +1
-1-void update_atime (struct inode *inode) +void update_atime (struct inode *inode,struct vfsmount *mnt)
_Hell_, no. Proper solution is to move the callers upstream instead of propagating vfsmounts downstream. That, BTW, was the main reason for readdir() patch.
BTW, update_atime() is exported. And it's 2.6 now...
Re: [PATCH] Bind Mount Extensions 0.04.1 2/5
Quoted 3 lines · On Thu, Mar 18, 2004 at 12:16:50PM +0000…
Review
Quoted 2 lines · Herbert Poetzl
(quoted diff) +1
-1-void update_atime(struct inode *inode) +void update_atime(struct inode *inode, struct vfsmount *mnt)
Hi Alexander!
Quoted 1 line
_Hell_, no.
thanks for looking at the code ;)
Quoted 3 lines
Proper solution is to move the callers upstream instead of propagating vfsmounts downstream. That, BTW, was the main reason for
readdir()patch.
it that what you have in mind?
-· update_atime()
¦-· __generic_file_aio_read() [done]
¦
¦-· autofs4_update_usage() [removed]
¦ ¦-· autofs4_revalidate() [done]
¦ ¦-· autofs4_root_revalidate() [done]
¦ ¦-· try_to_fill_dentry() [done,NULL]
¦ '-· try_to_fill_dentry() [done,NULL]
¦
¦-· coda_readdir() [done]
¦-· do_follow_link() [done]
¦-· do_generic_mapping_read() [done]
¦-· do_shmem_file_read() [done]
¦
¦-· generic_file_mmap() [done]
¦-· hugetlbfs_file_mmap() [done]
¦
¦-· nfsd_readlink() [done]
¦-· open_namei() [done]
¦-· pipe_readv() [done]
¦-· random_read() [done]
¦-· shmem_mmap() [done]
¦-· sys_readlink() [done]
¦
¦-· unix_find_other() [done,NULL]
¦
'-· vfs_readdir() [done]
Quoted 1 line
BTW,
update_atime()is exported. And it's 2.6 now...
patch is also available at:
http://www.13thfloor.at/patches/patch-2.6.5-rc1-bk3-bme0.04.2-atime.diff
best,
Herbert
drivers/char/random.c +2 -2
@@ -1640,9 +1640,9 @@ random_read(struct file * file, char * b/* * If we gave the user some bytes, update the access time. */ -if (count !=0 ) { +if ((count !=0 ) && +may_update_atime (file->f_dentry->d_inode, file->f_vfsmnt))update_atime (file->f_dentry->d_inode); - }return (count ? count : retval); }
fs/autofs/root.c +3 -1
@@ -129,8 +129,10 @@ static int try_to_fill_dentry(struct den/* We don't update the usages for the autofs daemon itself, this is necessary for recursive autofs mounts */ -if ( !autofs_oz_mode (sbi) ) { +if (!autofs_oz_mode (sbi)) {autofs_update_usage (&sbi->dirhash,ent); +if (may_update_atime (dentry->d_inode,NULL )) +update_atime (dentry->d_inode); } dentry->d_flags &= ~DCACHE_AUTOFS_PENDING ;
fs/autofs4/root.c +15 -8
@@ -15,6 +15,8 @@#include <linux/stat.h> #include <linux/param.h> #include <linux/time.h> +#include <linux/fs.h> +#include <linux/namei.h> #include <linux/smp_lock.h> #include "autofs_i.h"
@@ -60,10 +62,8 @@ static void autofs4_update_usage(structfor (; dentry != top; dentry = dentry->d_parent) {struct autofs_info *ino =autofs4_dentry_ino (dentry); -if (ino) { -update_atime (dentry->d_inode); +if (ino) ino->last_used = jiffies; - } } }
@@ -129,8 +129,11 @@ static int try_to_fill_dentry(struct den/* We don't update the usages for the autofs daemon itself, this is necessary for recursive autofs mounts */ -if (!autofs4_oz_mode (sbi)) +if (!autofs4_oz_mode (sbi)) {autofs4_update_usage (dentry); +if (may_update_atime (dentry->d_inode,NULL )) +update_atime (dentry->d_inode); + } dentry->d_flags &= ~DCACHE_AUTOFS_PENDING ;return 1 ;
@@ -177,9 +180,11 @@ static int autofs4_root_revalidate(strucspin_unlock (&dcache_lock);/* Update the usage list */ -if (!oz_mode) +if (!oz_mode) {autofs4_update_usage (dentry); - +if (may_update_atime (dentry->d_inode, nd->mnt)) +update_atime (dentry->d_inode); + }return 1 ; }
@@ -187,9 +192,11 @@ static int autofs4_revalidate(struct den {struct autofs_sb_info *sbi =autofs4_sbi (dentry->d_sb); -if (!autofs4_oz_mode (sbi)) +if (!autofs4_oz_mode (sbi)) {autofs4_update_usage (dentry); - +if (may_update_atime (dentry->d_inode, nd->mnt)) +update_atime (dentry->d_inode); + }return 1 ; }
fs/coda/dir.c +2 -1
@@ -512,7 +512,8 @@ int coda_readdir(struct file *coda_file, ret = -ENOENT ;if (!IS_DEADDIR (host_inode)) { ret = host_file->f_op->readdir (host_file, filldir, dirent); -update_atime (host_inode); +if (may_update_atime (host_inode, host_file->f_vfsmnt)) +update_atime (host_inode); } } out:
fs/hugetlbfs/inode.c +2 -1
@@ -62,7 +62,8 @@ static int hugetlbfs_file_mmap(struct fi vma_len = (loff_t)(vma->vm_end - vma->vm_start);down (&inode->i_sem); -update_atime (inode); +if (may_update_atime (inode, file->f_vfsmnt)) +update_atime (inode); vma->vm_flags |=VM_HUGETLB |VM_RESERVED ; vma->vm_ops = &hugetlb_vm_ops; ret =hugetlb_prefault (mapping, vma);
fs/inode.c +0 -7
@@ -1145,13 +1145,6 @@ void update_atime(struct inode *inode) {struct timespec now; -if (IS_NOATIME (inode)) -return ; -if (IS_NODIRATIME (inode) &&S_ISDIR (inode->i_mode)) -return ; -if (IS_RDONLY (inode)) -return ; - now =current_kernel_time ();if (inode_times_differ (inode, &inode->i_atime, &now)) { inode->i_atime = now;
fs/namei.c +4 -2
@@ -412,7 +412,8 @@ static inline int do_follow_link(struct goto loop; current->link_count++; current->total_link_count++; -update_atime (dentry->d_inode); +if (may_update_atime (dentry->d_inode, nd->mnt)) +update_atime (dentry->d_inode); err = dentry->d_inode->i_op->follow_link (dentry, nd); current->link_count--;return err;
@@ -1368,7 +1369,8 @@ do_link: error =security_inode_follow_link (dentry, nd);if (error) goto exit_dput; -update_atime (dentry->d_inode); +if (may_update_atime (dentry->d_inode, nd->mnt)) +update_atime (dentry->d_inode); error = dentry->d_inode->i_op->follow_link (dentry, nd);dput (dentry);if (error)
fs/namespace.c +36 -25
109 lines not on this page · raw message
fs/nfsd/vfs.c +2 -1
@@ -1143,7 +1143,8 @@ nfsd_readlink(struct svc_rqst *rqstp, stif (!inode->i_op || !inode->i_op->readlink) goto out; -update_atime (inode); +if (may_update_atime (inode, fhp->fh_export->ex_mnt)) +update_atime (inode);/* N.B. Why does this call need a get_fs()?? * Remove the set_fs and watch the fireworks:-) --okir */
fs/pipe.c +2 -1
@@ -164,7 +164,8 @@ pipe_readv(struct file *filp, const struwake_up_interruptible (PIPE_WAIT (*inode));kill_fasync (PIPE_FASYNC_WRITERS (*inode),SIGIO ,POLL_OUT ); } -if (ret >0 ) +if ((ret >0 ) && +may_update_atime (inode, filp->f_vfsmnt))update_atime (inode);return ret; }
fs/readdir.c +2 -1
@@ -32,7 +32,8 @@ int vfs_readdir(struct file *file, filld res = -ENOENT ;if (!IS_DEADDIR (inode)) { res = file->f_op->readdir (file, buf, filler); -update_atime (inode); +if (may_update_atime (inode, file->f_vfsmnt)) +update_atime (inode); }up (&inode->i_sem); out:
fs/stat.c +2 -1
@@ -272,7 +272,8 @@ asmlinkage long sys_readlink(const charif (inode->i_op && inode->i_op->readlink) { error =security_inode_readlink (nd.dentry);if (!error) { -update_atime (inode); +if (may_update_atime (inode, nd.mnt)) +update_atime (inode); error = inode->i_op->readlink (nd.dentry, buf, bufsiz); } }
include/linux/fs.h +17 -0
@@ -19,6 +19,7 @@#include <linux/cache.h> #include <linux/radix-tree.h> #include <linux/kobject.h> +#include <linux/mount.h> #include <asm/atomic.h> struct iovec ;
@@ -751,6 +753,22 @@ extern int vfs_rmdir(struct inode *, strextern int vfs_unlink (struct inode *,struct dentry *);extern int vfs_rename (struct inode *,struct dentry *,struct inode *,struct dentry *); +static inline int may_update_atime (struct inode *inode,struct vfsmount *mnt) +{ +if (IS_RDONLY (inode) || + (mnt &&MNT_IS_RDONLY (mnt))) +return 0 ; +if (IS_NOATIME (inode) || + (mnt &&MNT_IS_NOATIME (mnt))) +return 0 ; +if (S_ISDIR (inode->i_mode) && + (IS_NODIRATIME (inode) || + (mnt &&MNT_IS_NODIRATIME (mnt)))) +return 0 ; +return 1 ; +} + +/* * File types *
include/linux/mount.h +10 -3
@@ -14,9 +14,12 @@#include <linux/list.h> -#define MNT_NOSUID 1 -#define MNT_NODEV 2 -#define MNT_NOEXEC 4 +#define MNT_RDONLY 1 +#define MNT_NOSUID 2 +#define MNT_NODEV 4 +#define MNT_NOEXEC 8 +#define MNT_NOATIME 1024 +#define MNT_NODIRATIME 2048struct vfsmount {
@@ -33,6 +36,10 @@ struct vfsmountstruct list_head mnt_list; }; +#define MNT_IS_RDONLY (m) ((m) && ((m)->mnt_flags & MNT_RDONLY)) +#define MNT_IS_NOATIME (m) ((m) && ((m)->mnt_flags & MNT_NOATIME)) +#define MNT_IS_NODIRATIME (m) ((m) && ((m)->mnt_flags & MNT_NODIRATIME)) +static inline struct vfsmount *mntget (struct vfsmount *mnt) {if (mnt)
mm/filemap.c +7 -3
@@ -21,6 +21,7 @@#include <linux/mman.h> #include <linux/pagemap.h> #include <linux/file.h> +#include <linux/mount.h> #include <linux/uio.h> #include <linux/hash.h> #include <linux/writeback.h>
@@ -725,7 +726,8 @@ no_cached_page: *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset;if (cached_page)page_cache_release (cached_page); -update_atime (inode); +if (may_update_atime (inode, filp->f_vfsmnt)) +update_atime (inode); }EXPORT_SYMBOL (do_generic_mapping_read);
@@ -820,7 +822,8 @@ __generic_file_aio_read(struct kiocb *ioif (retval >0 ) *ppos = pos + retval; } -update_atime (filp->f_dentry->d_inode); +if (may_update_atime (filp->f_dentry->d_inode, filp->f_vfsmnt)) +update_atime (filp->f_dentry->d_inode); goto out; }
@@ -1357,7 +1360,8 @@ int generic_file_mmap(struct file * fileif (!mapping->a_ops->readpage)return -ENOEXEC ; -update_atime (inode); +if (may_update_atime (inode, file->f_vfsmnt)) +update_atime (inode); vma->vm_ops = &generic_file_vm_ops;return 0 ; }
mm/shmem.c +4 -2
@@ -1067,7 +1067,8 @@ static int shmem_mmap(struct file *file, ops = &shmem_vm_ops;if (!S_ISREG (inode->i_mode))return -EACCES ; -update_atime (inode); +if (may_update_atime (inode, file->f_vfsmnt)) +update_atime (inode); vma->vm_ops = ops;return 0 ; }
@@ -1363,7 +1364,8 @@ static void do_shmem_file_read(struct fi } *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset; -update_atime (inode); +if (may_update_atime (inode, filp->f_vfsmnt)) +update_atime (inode); }static ssize_t shmem_file_read (struct file *filp,char __user *buf,size_t count,loff_t *ppos)
net/unix/af_unix.c +1 -1
@@ -706,7 +706,7 @@ static struct sock *unix_find_other(struif (u) {struct dentry *dentry; dentry =unix_sk (u)->dentry; -if (dentry) +if (dentry &&may_update_atime (dentry->d_inode,NULL ))update_atime (dentry->d_inode); }else goto fail;
Re: [PATCH] Bind Mount Extensions 0.04.1 2/5
In reply to [email protected]Quoted 7 lines · On Thu, Mar 18, 2004 at 12:16:50PM +0000…
fs/inode.c static int inode_times_differ(struct ino · line 1145
Quoted 2 lines · Herbert Poetzl
fs/inode.c +1
-1-void update_atime (struct inode *inode) +void update_atime (struct inode *inode,struct vfsmount *mnt)_Hell_, no. Proper solution is to move the callers upstream instead of propagating vfsmounts downstream. That, BTW, was the main reason for
readdir()patch.
# 04/03/18 [email protected] 1.1795.6.4
# [PATCH] add touch_atime() helper
#
# Preparation for per-mountpoint noatime, nodiratime and later -
# per-mountpoint r/o. Depends on file_accessed() patch, should go after # it. # # New helper - touch_atime(mnt, dentry). It's a wrapper for # update_atime() and that's where all future per-mountpoint checks will # go.
static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
{
/* per-mountpoint checks will go here */
update_atime(dentry->d_inode);
}Hum, so that is what you call 'moving the callers upstream' instead of 'propagating vfsmounts downstream' ...
best,
Herbert
Quoted 6 lines
BTW,
update_atime()is exported. And it's 2.6 now...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 1/1 Bind Mount Extensions 0.04.1 4/5
In reply to Andrew Mortonfs/namei.c +3 -3
@@ -156,15 +156,15 @@ char * getname(const char __user * filen* for filesystem access without changing the "normal" uids which * are used for other things.. */ -int vfs_permission (struct inode * inode,int mask) +int vfs_permission (struct inode * inode,int mask,struct nameidata *nd) { -umode_t mode = inode->i_mode; +umode_t mode = inode->i_mode;if (mask &MAY_WRITE ) {/* * Nobody gets write access to a read-only fs. */ -if (IS_RDONLY (inode) && +if (IS_RDONLY (inode, nd ? nd->mnt :NULL ) && (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)))return -EROFS ;
fs/ext2/acl.c +2 -1
@@ -291,7 +292,8 @@ ext2_permission(struct inode *inode, intint mode = inode->i_mode;/* Nobody gets write access to a read-only fs */ -if ((mask &MAY_WRITE ) &&IS_RDONLY (inode) && +if ((mask &MAY_WRITE ) && + (IS_RDONLY (inode, nd ? nd->mnt :NULL )) && (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)))return -EROFS ;/* Nobody gets write access to an immutable file */
fs/ext3/acl.c +2 -1
@@ -296,7 +296,8 @@ ext3_permission(struct inode *inode, intint mode = inode->i_mode;/* Nobody gets write access to a read-only fs */ -if ((mask &MAY_WRITE ) &&IS_RDONLY (inode) && +if ((mask &MAY_WRITE ) && + (IS_RDONLY (inode, nd ? nd->mnt :NULL )) && (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)))return -EROFS ;/* Nobody gets write access to an immutable file */
fs/jfs/acl.c +1 -1
@@ -136,7 +136,7 @@ int jfs_permission(struct inode * inode,/* * Nobody gets write access to a read-only fs. */ -if (IS_RDONLY (inode) && +if (IS_RDONLY (inode, nd ? nd->mnt :NULL ) && (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)))return -EROFS ;
PATCH 1/1 Bind Mount Extensions 0.04.1 3/5
In reply to Andrew Mortoninclude/linux/posix_acl.h +1 -0
@@ -9,6 +9,7 @@#define __LINUX_POSIX_ACL_H#include <linux/slab.h> +#include <linux/namei.h> #define ACL_UNDEFINED_ID (-1)
include/linux/fs.h +4 -2
@@ -19,6 +19,7 @@#include <linux/cache.h> #include <linux/radix-tree.h> #include <linux/kobject.h> +#include <linux/mount.h> #include <asm/atomic.h> struct iovec ;
@@ -155,7 +156,8 @@ extern int leases_enable, dir_notify_ena*/ #define __IS_FLG (inode,flg) ((inode)->i_sb->s_flags & (flg)) -#define IS_RDONLY (inode) ((inode)->i_sb->s_flags & MS_RDONLY) +#define IS_RDONLY_INODE (inode) ((inode)->i_sb->s_flags & MS_RDONLY) +#define IS_RDONLY (inode,mount) (IS_RDONLY_INODE(inode) || MNT_IS_RDONLY(mount))#define IS_SYNC (inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \ ((inode)->i_flags & S_SYNC))#define IS_DIRSYNC (inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
@@ -1226,7 +1228,7 @@ extern sector_t bmap(struct inode *, secextern int setattr_mask (unsigned int );extern int notify_change (struct dentry *,struct iattr *);extern int permission (struct inode *,int ,struct nameidata *); -extern int vfs_permission (struct inode *,int ); +extern int vfs_permission (struct inode *,int ,struct nameidata *);extern int get_write_access (struct inode *);extern int deny_write_access (struct file *);static inline void put_write_access (struct inode * inode)
fs/open.c +13 -12
@@ -226,7 +226,7 @@ static inline long do_sys_truncate(const goto dput_and_out; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, nd.mnt)) goto dput_and_out; error = -EPERM ;
@@ -350,7 +350,7 @@ asmlinkage long sys_utime(char __user * inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, nd.mnt)) goto dput_and_out;/* Don't worry, the checks are done in inode_change_ok() */
@@ -407,7 +407,7 @@ long do_utimes(char __user * filename, s inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, nd.mnt)) goto dput_and_out;/* Don't worry, the checks are done in inode_change_ok() */
@@ -489,8 +489,9 @@ asmlinkage long sys_access(const char __if (!res) { res =permission (nd.dentry->d_inode, mode, &nd);/* SuS v2 requires we report a read only fs too */ -if (!res && (mode &S_IWOTH ) &&IS_RDONLY (nd.dentry->d_inode) - && !special_file (nd.dentry->d_inode->i_mode)) +if (!res && (mode &S_IWOTH ) + && !special_file (nd.dentry->d_inode->i_mode) + && (IS_RDONLY (nd.dentry->d_inode, nd.mnt))) res = -EROFS ;path_release (&nd); }
@@ -595,7 +596,7 @@ asmlinkage long sys_fchmod(unsigned int inode = dentry->d_inode; err = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, file->f_vfsmnt)) goto out_putf; err = -EPERM ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))
@@ -627,7 +628,7 @@ asmlinkage long sys_chmod(const char __u inode = nd.dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, nd.mnt)) goto dput_and_out; error = -EPERM ;
@@ -648,7 +649,7 @@ out:return error; } -static int chown_common (struct dentry * dentry,uid_t user,gid_t group) +static int chown_common (struct vfsmount *mnt,struct dentry * dentry,uid_t user,gid_t group) {struct inode * inode;int error;
@@ -660,7 +661,7 @@ static int chown_common(struct dentry * goto out; } error = -EROFS ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, mnt)) goto out; error = -EPERM ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))
@@ -690,7 +691,7 @@ asmlinkage long sys_chown(const char __u error =user_path_walk (filename, &nd);if (!error) { - error =chown_common (nd.dentry, user, group); + error =chown_common (nd.mnt, nd.dentry, user, group);path_release (&nd); }return error;
@@ -703,7 +704,7 @@ asmlinkage long sys_lchown(const char __ error =user_path_walk_link (filename, &nd);if (!error) { - error =chown_common (nd.dentry, user, group); + error =chown_common (nd.mnt, nd.dentry, user, group);path_release (&nd); }return error;
@@ -717,7 +718,7 @@ asmlinkage long sys_fchown(unsigned int file =fget (fd);if (file) { - error =chown_common (file->f_dentry, user, group); + error =chown_common (file->f_vfsmnt, file->f_dentry, user, group);fput (file); }return error;
fs/namei.c +46 -9
115 lines not on this page · raw message
arch/sparc64/solaris/fs.c +2 -2
@@ -405,7 +405,7 @@ static int report_statvfs(struct vfsmounint j =strlen (p);if (j >15 ) j =15 ; -if (IS_RDONLY (inode)) i =1 ; +if (IS_RDONLY (inode, mnt)) i =1 ;if (mnt->mnt_flags &MNT_NOSUID ) i |=2 ;if (!sysv_valid_dev (inode->i_sb->s_dev))return -EOVERFLOW ;
@@ -441,7 +441,7 @@ static int report_statvfs64(struct vfsmoint j =strlen (p);if (j >15 ) j =15 ; -if (IS_RDONLY (inode)) i =1 ; +if (IS_RDONLY (inode, mnt)) i =1 ;if (mnt->mnt_flags &MNT_NOSUID ) i |=2 ;if (!sysv_valid_dev (inode->i_sb->s_dev))return -EOVERFLOW ;
fs/ext2/ioctl.c +2 -2
@@ -29,7 +30,7 @@ int ext2_ioctl (struct inode * inode, stcase EXT2_IOC_SETFLAGS : {unsigned int oldflags; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -68,7 +69,7 @@ int ext2_ioctl (struct inode * inode, stcase EXT2_IOC_SETVERSION :if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if (get_user (inode->i_generation, (int *) arg))return -EFAULT ;
fs/ext2/xattr.c +1 -1
@@ -496,7 +496,7 @@ ext2_xattr_set(struct inode *inode, intea_idebug (inode,"name=%d.%s, value=%p, value_len=%ld" , name_index, name, value, (long )value_len); -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))return -EROFS ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;
fs/ext3/ioctl.c +2 -2
@@ -34,7 +35,7 @@ int ext3_ioctl (struct inode * inode, stunsigned int oldflags;unsigned int jflag; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -110,7 +111,7 @@ flags_err:if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if (get_user (generation, (int *) arg))return -EFAULT ;
fs/ext3/xattr.c +1 -1
@@ -496,7 +496,7 @@ ext3_xattr_set_handle(handle_t *handle,ea_idebug (inode,"name=%d.%s, value=%p, value_len=%ld" , name_index, name, value, (long )value_len); -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))return -EROFS ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;
fs/hfs/inode.c +1 -1
@@ -516,7 +516,7 @@ static int hfs_permission(struct inode * {if (S_ISREG (inode->i_mode) && mask &MAY_EXEC )return 0 ; -return vfs_permission (inode, mask); +return vfs_permission (inode, mask, nd); }static int hfs_file_open (struct inode *inode,struct file *file)
fs/hfsplus/inode.c +1 -1
@@ -260,7 +260,7 @@ static int hfsplus_permission(struct ino*/ if (S_ISREG (inode->i_mode) && mask &MAY_EXEC && !(inode->i_mode &0111 ))return 0 ; -return vfs_permission (inode, mask); +return vfs_permission (inode, mask, nd); }
fs/intermezzo/dir.c +1 -1
@@ -864,7 +864,7 @@ int presto_permission(struct inode *inod/* The cache filesystem doesn't have its own permission function, * so we call the default one. */ - rc =vfs_permission (inode, mask); + rc =vfs_permission (inode, mask, nd);EXIT ;return rc;
fs/intermezzo/vfs.c +3 -3
@@ -258,7 +258,7 @@ int presto_settime(struct presto_file_se inode = dentry->d_inode; error = -EROFS ; -if (IS_RDONLY (inode)) { +if (IS_RDONLY_INODE (inode)) {EXIT ;return -EROFS ; }
@@ -373,7 +373,7 @@ int presto_do_setattr(struct presto_fileENTRY ; error = -EROFS ; -if (IS_RDONLY (inode)) { +if (IS_RDONLY_INODE (inode)) {EXIT ;return -EROFS ; }
@@ -2316,7 +2316,7 @@ int presto_do_set_ext_attr(struct prestoENTRY ; error = -EROFS ; -if (IS_RDONLY (inode)) { +if (IS_RDONLY_INODE (inode)) {EXIT ;return -EROFS ; }
fs/hfsplus/ioctl.c +1 -1
@@ -33,7 +33,7 @@ int hfsplus_ioctl(struct inode *inode, s flags |=EXT2_FLAG_NODUMP ;/* EXT2_NODUMP_FL */ return put_user (flags, (int *)arg);case HFSPLUS_IOC_EXT2_SETFLAGS : { -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
fs/inode.c +2 -2
@@ -1173,14 +1175,14 @@ EXPORT_SYMBOL(update_atime);* When ctime_too is specified update the ctime too. */ -void inode_update_time (struct inode *inode,int ctime_too) +void inode_update_time (struct inode *inode,int ctime_too,struct vfsmount *mount) {struct timespec now;int sync_it =0 ;if (IS_NOCMTIME (inode))return ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, mount))return ; now =current_kernel_time ();
fs/nfs/dir.c +4 -3
@@ -778,7 +778,8 @@ static int is_atomic_open(struct inode *if (nd->flags &LOOKUP_DIRECTORY )return 0 ;/* Are we trying to write to a read only partition? */ -if (IS_RDONLY (dir) && (nd->intent.open.flags & (O_CREAT |O_TRUNC |FMODE_WRITE ))) +if (IS_RDONLY (dir, nd->mnt) && + (nd->intent.open.flags & (O_CREAT |O_TRUNC |FMODE_WRITE )))return 0 ;return 1 ; }
@@ -1514,7 +1515,7 @@ nfs_permission(struct inode *inode, int* Nobody gets write access to a read-only fs. * */ -if (IS_RDONLY (inode) && +if (IS_RDONLY (inode, nd->mnt) && (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)))return -EROFS ;
@@ -1565,7 +1566,7 @@ out:return res; out_notsup:nfs_revalidate_inode (NFS_SERVER (inode), inode); - res =vfs_permission (inode, mask); + res =vfs_permission (inode, mask, nd);unlock_kernel ();return res; add_cache:
fs/proc/base.c +1 -1
@@ -449,7 +449,7 @@ out:static int proc_permission (struct inode *inode,int mask,struct nameidata *nd) { -if (vfs_permission (inode, mask) !=0 ) +if (vfs_permission (inode, mask, nd) !=0 )return -EACCES ;return proc_check_root (inode); }
fs/reiserfs/ioctl.c +2 -2
@@ -38,7 +39,7 @@ int reiserfs_ioctl (struct inode * inodei_attrs_to_sd_attrs ( inode, (__u16 * ) &flags );return put_user (flags, (int *) arg);case REISERFS_IOC_SETFLAGS : { -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))
@@ -70,7 +71,7 @@ int reiserfs_ioctl (struct inode * inodecase REISERFS_IOC_SETVERSION :if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER ))return -EPERM ; -if (IS_RDONLY (inode)) +if (IS_RDONLY (inode, filp->f_vfsmnt))return -EROFS ;if (get_user (inode->i_generation, (int *) arg))return -EFAULT ;
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
fs/ext2/xattr.c ext2_xattr_set(struct inode *inode, int · line 499
Quoted 9 lines · Herbert Poetzl
fs/ext2/xattr.c +1
-1@@ -496,7 +496,7 @@ ext2_xattr_set(struct inode *inode, intea_idebug (inode,"name=%d.%s, value=%p, value_len=%ld" , name_index, name, value, (long )value_len); -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))
I do think that if we're going to do this thing it should have 100% coverage, and not have little exceptions because the volume of changes got too high.
The number of places where you need IS_RDONLY_INODE() are encouragingly small. It appears that all we need to do to get rid of it is to propagate the file* down through the ext2 and ext3 xattr code. A NULL value will need to be permitted because ext2_new_inode doesn't have a file*, and we've already performed the check.
Sure, it's a largeish patch but it is very safe: if it compiles, it works.
Could you please work that with Andreas?
IS_RDONLY_INODE() is also used in intermezzo, but that doesn't compile any more anyway.
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 15 lines · Andrew Morton
fs/ext2/xattr.c ext2_xattr_set(struct inode *inode, int · line 499
Quoted 9 lines · Herbert Poetzl
fs/ext2/xattr.c +1
-1@@ -496,7 +496,7 @@ ext2_xattr_set(struct inode *inode, intea_idebug (inode,"name=%d.%s, value=%p, value_len=%ld" , name_index, name, value, (long )value_len); -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))I do think that if we're going to do this thing it should have 100% coverage, and not have little exceptions because the volume of changes got too high.
Quoted 5 lines
The number of places where you need
IS_RDONLY_INODE()are encouragingly small. It appears that all we need to do to get rid of it is to propagate the file* down through the ext2 and ext3 xattr code. A NULL value will need to be permitted becauseext2_new_inodedoesn't have a file*, and we've already performed the check.
I'm not sure we actually want to do this, but I'll try ... seems to go up all the way to the syscall entry.
Quoted 1 line
Sure, it's a largeish patch but it is very safe: if it compiles, it works.
agreed.
Quoted 1 line
Could you please work that with Andreas?
sure, Andreas who?
Quoted 2 lines
IS_RDONLY_INODE()is also used in intermezzo, but that doesn't compile any more anyway.
so I do not bother with that, but what about the nfs(d) stuff?
TIA,
Herbert
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 4 lines · Herbert Poetzl
Quoted 2 lines
Could you please work that with Andreas?
sure, Andreas who?
Andreas Gruenbacher <[email protected]>
Quoted 5 lines
Quoted 2 lines
IS_RDONLY_INODE()is also used in intermezzo, but that doesn't compile any more anyway.so I do not bother with that, but what about the nfs(d) stuff?
er, what nfs stuff? Your patches only have IS_RDONLY_INODE() being used in the ext2/3 xattr code and in intermezzo.
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Herbert Poetzl
Quoted 2 lines
Could you please work that with Andreas?
sure, Andreas who?
Andreas Gruenbacher <[email protected]>
okay, will contact him ...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
IS_RDONLY_INODE()is also used in intermezzo, but that doesn't compile any more anyway.so I do not bother with that, but what about the nfs(d) stuff?
er, what nfs stuff? Your patches only have
IS_RDONLY_INODE()being used in the ext2/3 xattr code and in intermezzo.
hmm, I guess nfsd_permission() can be considered nfs stuff, but I'll look into that anyway, maybe Trond can help here ... (patch-2.6.4-20040314_2308-bme0.04.1-ro3.diff 5/5)
best,
Herbert
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
In reply to Herbert Poetzlinclude/linux/fs.h extern sector_t bmap(struct inode *, sec · line 1231
Quoted 2 lines · Herbert Poetzl
include/linux/fs.h +1
-1-extern int vfs_permission (struct inode *,int ); +extern int vfs_permission (struct inode *,int ,struct nameidata *);
Vetoed, along with IS_RDONLY() prototype change.
Note that you are doing exactly the opposite of the changes we'll need to deal with remount races.
What we need is to push readonly checks _up_ - into callers of fs methods. vfs_permission() is default ->permission() - no more, no less. Neither it nor other instances have any business touching "this vfsmount is readonly" logics - it's not something where fs can override stuff; it's "admin said no r/w access here".
IOW, the check for r/w access to file/directory/symlink on a r/o mount should be moved into the callers (very few of them) of ->permission() and away from the methods themselves.
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 5 lines · On Thu, Mar 18, 2004 at 12:26:45PM +0000…
Review
Quoted 2 lines · Herbert Poetzl
(quoted diff) +1
-1-extern int vfs_permission(struct inode *, int); +extern int vfs_permission(struct inode *, int, struct nameidata *);Vetoed, along with
IS_RDONLY()prototype change.
hmm, that is what I expected ...
Quoted 9 lines
Note that you are doing exactly the opposite of the changes we'll need to deal with remount races.
What we need is to push readonly checks _up_ - into callers of fs methods.
vfs_permission()is default ->permission() - no more, no less. Neither it nor other instances have any business touching "this vfsmount is readonly" logics - it's not something where fs can override stuff; it's "admin said no r/w access here".
Quoted 3 lines
IOW, the check for r/w access to file/directory/symlink on a r/o mount should be moved into the callers (very few of them) of ->permission() and away from the methods themselves.
maybe like this ...
patch can be downloaded at:
http://www.13thfloor.at/patches/patch-2.6.5-rc1-bk3-bme0.04.2-permission.diff
best,
Herbert
fs/ext2/acl.c +0 -7
@@ -290,13 +290,6 @@ ext2_permission(struct inode *inode, int {int mode = inode->i_mode; -/* Nobody gets write access to a read-only fs */ -if ((mask &MAY_WRITE ) &&IS_RDONLY (inode) && - (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode))) -return -EROFS ; -/* Nobody gets write access to an immutable file */ -if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) -return -EACCES ;if (current->fsuid == inode->i_uid) { mode >>=6 ; }else if (test_opt (inode->i_sb,POSIX_ACL )) {
fs/ext3/acl.c +0 -7
@@ -295,13 +295,6 @@ ext3_permission(struct inode *inode, int {int mode = inode->i_mode; -/* Nobody gets write access to a read-only fs */ -if ((mask &MAY_WRITE ) &&IS_RDONLY (inode) && - (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode))) -return -EROFS ; -/* Nobody gets write access to an immutable file */ -if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) -return -EACCES ;if (current->fsuid == inode->i_uid) { mode >>=6 ; }else if (test_opt (inode->i_sb,POSIX_ACL )) {
fs/intermezzo/dir.c +10 -0
@@ -846,6 +846,16 @@ int presto_permission(struct inode *inod cache =presto_get_cache (inode); +/* Nobody gets write access to a read-only fs */ +if ((mask &MAY_WRITE ) && + (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)) && + (IS_RDONLY (inode) || (nd &&MNT_IS_RDONLY (nd->mnt)))) +return -EROFS ; + +/* Nobody gets write access to an immutable file */ +if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) +return -EACCES ; +if ( cache ) {/* we only override the file/dir permission operations */ struct inode_operations *fiops =filter_c2cfiops (cache->cache_filter);
fs/jfs/acl.c +0 -15
@@ -132,21 +132,6 @@ int jfs_permission(struct inode * inode,umode_t mode = inode->i_mode;struct jfs_inode_info *ji =JFS_IP (inode); -if (mask &MAY_WRITE ) { -/* -* Nobody gets write access to a read-only fs. -*/ -if (IS_RDONLY (inode) && - (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode))) -return -EROFS ; - -/* -* Nobody gets write access to an immutable file. -*/ -if (IS_IMMUTABLE (inode)) -return -EACCES ; - } -if (current->fsuid == inode->i_uid) { mode >>=6 ; goto check_mode;
fs/namei.c +11 -15
@@ -160,21 +160,6 @@ int vfs_permission(struct inode * inode, {umode_t mode = inode->i_mode; -if (mask &MAY_WRITE ) { -/* -* Nobody gets write access to a read-only fs. -*/ -if (IS_RDONLY (inode) && - (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode))) -return -EROFS ; - -/* -* Nobody gets write access to an immutable file. -*/ -if (IS_IMMUTABLE (inode)) -return -EACCES ; - } -if (current->fsuid == inode->i_uid) mode >>=6 ;else if (in_group_p (inode->i_gid))
@@ -207,9 +192,20 @@ int vfs_permission(struct inode * inode,int permission (struct inode * inode,int mask,struct nameidata *nd) { +int mode = inode->i_mode;int retval;int submask; +/* Nobody gets write access to a read-only fs */ +if ((mask &MAY_WRITE ) && + (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)) && + (IS_RDONLY (inode) || (nd &&MNT_IS_RDONLY (nd->mnt)))) +return -EROFS ; + +/* Nobody gets write access to an immutable file */ +if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) +return -EACCES ; +/* Ordinary permission routines do not understand MAY_APPEND. */ submask = mask & ~MAY_APPEND ;
fs/nfs/dir.c +0 -18
@@ -1503,29 +1503,11 @@ nfs_permission(struct inode *inode, int {struct nfs_access_cache *cache = &NFS_I (inode)->cache_access;struct rpc_cred *cred; -int mode = inode->i_mode;int res;if (mask ==0 )return 0 ; -if (mask &MAY_WRITE ) { -/* -* -* Nobody gets write access to a read-only fs. -* -*/ -if (IS_RDONLY (inode) && - (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode))) -return -EROFS ; -/* -* -* Nobody gets write access to an immutable file. -* -*/ -if (IS_IMMUTABLE (inode)) -return -EACCES ; - }/* Are we checking permissions on anything other than lookup/execute? */ if ((mask &MAY_EXEC ) ==0 ) {/* We only need to check permissions on file open() and access() */
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 4 lines · Herbert Poetzl
fs/intermezzo/dir.c +0
-0@@ -846,6 +846,16 @@ int presto_permission(struct inode *inod cache =presto_get_cache (inode);
fs/intermezzo/dir.c int presto_permission(struct inode *inod · line 858
Quoted 10 lines
fs/intermezzo/dir.c +10
-0+/* Nobody gets write access to a read-only fs */ +if ((mask &MAY_WRITE ) && + (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)) && + (IS_RDONLY (inode) || (nd &&MNT_IS_RDONLY (nd->mnt)))) +return -EROFS ; + +/* Nobody gets write access to an immutable file */ +if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) +return -EACCES ; +
That is gratitious, since the only way presto_setattr() is ever called is as ->permission().
fs/jfs/acl.c int jfs_permission(struct inode * inode, · line 136
Quoted 8 lines
fs/jfs/acl.c +0
-2@@ -132,21 +132,6 @@ int jfs_permission(struct inode * inode,umode_t mode = inode->i_mode;struct jfs_inode_info *ji =JFS_IP (inode); -if (mask &MAY_WRITE ) { -/*
... and that is broken, since jfs_permission() can be called directly.
FWIW, I would start with
1) split out simple_permission() - vfs_permission() sans the
r/o checks; vfs_permission() would call it and all in-tree calls of vfs_permission() would get expanded.
2) prove that all instances of ->permission() honour r/o checks.
Fix the broken ones (and yes, we do have them - e.g. hfs_permission() or bogus return values in proc_permission()), after we'd shown that it's safe. Note that it's not obvious - e.g. anything around ACLs or <barf> XFS ioctls is not just fscking ugly - it's brittle as hell and will require very careful treatment.
3) once that is done, put r/o checks into the beginning of
permission(9)
4) for all instances of ->permission(), move r/o checks in
the places that call that instance directly. Remove them from method itself.
And yes, #2 will hurt. Badly.
BTW, IS_RDONLY() part of that stuff will really hit the fan when you start touching the FPOS in fs/ext2/xattr.c and around it. Have fun...
Note that it's not enough to bring relevant vfsmount to every caller of IS_RDONLY() - if we are calling it to make sure that fs is not r/o, we _really_ want to make sure that it doesn't get remounted r/o just as IS_RDONLY() returns. And yes, there are real bugs in that area.
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 5 lines · On Fri, Mar 19, 2004 at 11:11:17AM +0000…
Quoted 4 lines · Herbert Poetzl
fs/intermezzo/dir.c +0
-0@@ -846,6 +846,16 @@ int presto_permission(struct inode *inod cache =presto_get_cache (inode);
Quoted 13 lines
fs/intermezzo/dir.c int presto_permission(struct inode *inod · line 858
Quoted 10 lines
fs/intermezzo/dir.c +10
-0+/* Nobody gets write access to a read-only fs */ +if ((mask &MAY_WRITE ) && + (S_ISREG (mode) ||S_ISDIR (mode) ||S_ISLNK (mode)) && + (IS_RDONLY (inode) || (nd &&MNT_IS_RDONLY (nd->mnt)))) +return -EROFS ; + +/* Nobody gets write access to an immutable file */ +if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) +return -EACCES ; +That is gratitious, since the only way
presto_setattr()is ever called is as ->permission().
you mean presto_permission(), and yes, so that can be removed
Quoted 10 lines
fs/jfs/acl.c int jfs_permission(struct inode * inode, · line 136
Quoted 8 lines
fs/jfs/acl.c +0
-2@@ -132,21 +132,6 @@ int jfs_permission(struct inode * inode,umode_t mode = inode->i_mode;struct jfs_inode_info *ji =JFS_IP (inode); -if (mask &MAY_WRITE ) { -/* ... and that is broken, since
jfs_permission()can be called directly.
incomplete, not broken ...
-· jfs_permission()
¦-· can_get_xattr()
¦ '-· __jfs_getxattr()
¦ ¦-· jfs_get_acl()
¦ ¦ ¦-· jfs_acl_chmod()
¦ ¦ ¦ '-· jfs_setattr()
¦ ¦ ¦
¦ ¦ ¦-· jfs_init_acl()
¦ ¦ ¦ ¦-· jfs_create()
¦ ¦ ¦ ¦-· jfs_mkdir()
¦ ¦ ¦ ¦-· jfs_mknod()
¦ ¦ ¦ '-· jfs_symlink()
¦ ¦ ¦
¦ ¦ '-= jfs_permission()
¦ ¦
¦ '-· jfs_getxattr()
¦
'-· can_set_xattr()
'-· __jfs_setxattr()
¦-· jfs_removexattr()
¦-· jfs_set_acl()
¦ ¦-= jfs_acl_chmod()
¦ '-= jfs_init_acl()
¦
'-· jfs_setxattr()
the xattr struff needs attention anyway, and many of the functions calling jfs_permission() directly or indirectly will have the check at a higher layer ...
Quoted 4 lines
FWIW, I would start with
1) split outsimple_permission()-vfs_permission()sans the
r/o checks;vfs_permission()would call it and all in-tree calls ofvfs_permission()would get expanded.
-· vfs_permission()
¦-· hfs_permission()
¦-· hfsplus_permission()
¦-· nfs_permission()
¦-* permission()
¦-· presto_permission()
'-· proc_permission()
please elaborate ...
Quoted 6 lines
2) prove that all instances of ->permission() honour r/o checks.
Fix the broken ones (and yes, we do have them - e.g.hfs_permission()or bogus return values inproc_permission()), after we'd shown that it's safe. Note that it's not obvious - e.g. anything around ACLs or <barf> XFS ioctls is not just fscking ugly - it's brittle as hell and will require very careful treatment.
okay, but why not do it in permission(), and make the few callers of vfs_permission use that one instead?
except for jfs_permission() and nfsd_permission() (which is hell enough) there are no direct calls of *_permission() ...
Quoted 2 lines
3) once that is done, put r/o checks into the beginning of
permission(9)
hmm, obviously you didn't read the patch at all, as that is exactly what I did, so please have a look at it ...
Quoted 5 lines
4) for all instances of ->permission(), move r/o checks in
the places that call that instance directly. Remove them from method itself.And yes, #2 will hurt. Badly.
I don't see why, please enlighten me ...
Quoted 7 lines
BTW,
IS_RDONLY()part of that stuff will really hit the fan when you start touching the FPOS infs/ext2/xattr.cand around it. Have fun...Note that it's not enough to bring relevant vfsmount to every caller of
IS_RDONLY()- if we are calling it to make sure that fs is not r/o, we _really_ want to make sure that it doesn't get remounted r/o just asIS_RDONLY()returns. And yes, there are real bugs in that area.
hmm, well but how would moving the ro checks around or adding them for the vfs mounts influence that?
I agree that this _is_ an issue but why should this _not_ happen with mount -o remount,ro /xy ?
best,
Herbert
Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Quoted 13 lines · Herbert Poetzl
Quoted 4 lines
FWIW, I would start with
1) split outsimple_permission()-vfs_permission()sans the
r/o checks;vfs_permission()would call it and all in-tree calls ofvfs_permission()would get expanded.-·
vfs_permission()
¦-·hfs_permission()
¦-·hfsplus_permission()
¦-·nfs_permission()
¦-*permission()
¦-·presto_permission()
'-·proc_permission()
Quoted 1 line
please elaborate ...
First chunk: replace calls of vfs_permission() with r/o checks + simple_permission(), _leaving_ vfs_permission() _itself_ _as-is_.
Quoted 9 lines
Quoted 6 lines
2) prove that all instances of ->permission() honour r/o checks.
Fix the broken ones (and yes, we do have them - e.g.hfs_permission()or bogus return values inproc_permission()), after we'd shown that it's safe. Note that it's not obvious - e.g. anything around ACLs or <barf> XFS ioctls is not just fscking ugly - it's brittle as hell and will require very careful treatment.okay, but why not do it in
permission(), and make the few callers ofvfs_permissionuse that one instead?
Filesystem code might be calling permission(9) and expecting (broken) behaviour from its own ->permission(). Switch to uniform behaviour would break such places, forcing us to compensate there. And analysis won't be fun.
Quoted 3 lines
except for
jfs_permission()andnfsd_permission()(which is hell enough) there are no direct calls of*_permission()...
fs code calling permission() is basically equivalent to direct call.
Quoted 5 lines
Quoted 2 lines
3) once that is done, put r/o checks into the beginning of
permission(9)hmm, obviously you didn't read the patch at all, as that is exactly what I did, so please have a look at it ...
Yes, I have read it. Try to read the reply - what I'm saying is that it should be a separate chunk in the series _and_ it will need some preparations before it can go in.
Quoted 7 lines
Quoted 5 lines
4) for all instances of ->permission(), move r/o checks in
the places that call that instance directly. Remove them from method itself.And yes, #2 will hurt. Badly.
I don't see why, please enlighten me ...
See above.
Quoted 8 lines
Quoted 7 lines
BTW,
IS_RDONLY()part of that stuff will really hit the fan when you start touching the FPOS infs/ext2/xattr.cand around it. Have fun...Note that it's not enough to bring relevant vfsmount to every caller of
IS_RDONLY()- if we are calling it to make sure that fs is not r/o, we _really_ want to make sure that it doesn't get remounted r/o just asIS_RDONLY()returns. And yes, there are real bugs in that area.
Quoted 5 lines
hmm, well but how would moving the ro checks around or adding them for the vfs mounts influence that?
I agree that this _is_ an issue but why should this _not_ happen with mount -o remount,ro /xy ?
Once the checks are moved up, we split them into pairs (want_write_access(), drop_write_access()) where the former can fail. Then the second call gets moved past the call of fs method. IOW, we go from
start fs activity
deep in the bowels of fs code check for r/o and possibly fail do the rest
to
check for r/o and possibly fail
do fs work
_and_ to
request write access and possibly fail
do fs work
drop write access
Transition between (2) and (3) is simple and relatively easy to verify _IF_ the checks are lifted up. And result will give sane protection for remount - switch to r/o would have to be atomic wrt requesting write access and would fail if we had writers.
Note that per-mountpoint r/o will take pretty much the same amount of work - propagating vfsmounts down to the IS_RDONLY checks only to have that reverted when we lift the checks up would mean doing more or less the same twice.
It can be done and it can be merged gradually in small and simple chunks, so that they could be (a) well-understood and (b) well-tested.
The way we split the series *does* matter - composition of these patches will be large and will touch quite a few places (there's extra fun with delayed writes - e.g. removal of last link in foo_unlink() will mean extra request for write access, dropped when inode is finally deleted, possibly hours after unlink(2) had returned). Doing that in one or even 3-4 patches would be insane even in 2.7; in 2.6 it's so out of question that it's not even funny.
PATCH 1/1 Bind Mount Extensions 0.04.1 5/5
In reply to Andrew Mortonfs/xfs/xfs_inode.c +1 -1
@@ -3677,7 +3677,7 @@ xfs_iaccess(if (mode &S_IWUSR ) {umode_t imode = inode->i_mode; -if (IS_RDONLY (inode) && +if (IS_RDONLY_INODE (inode) && (S_ISREG (imode) ||S_ISDIR (imode) ||S_ISLNK (imode)))return XFS_ERROR (EROFS );
fs/nfsd/vfs.c +2 -2
@@ -1539,7 +1539,7 @@ nfsd_permission(struct svc_export *exp, inode->i_mode,IS_IMMUTABLE (inode)?" immut" :"" ,IS_APPEND (inode)?" append" :"" , - IS_RDONLY(inode)? " ro" : ""); + IS_RDONLY_INODE(inode)? " ro" : "");dprintk (" owner %d/%d user %d/%d\n" , inode->i_uid, inode->i_gid, current->fsuid, current->fsgid);#endif
@@ -1550,7 +1550,7 @@ nfsd_permission(struct svc_export *exp,*/ if (!(acc &MAY_LOCAL_ACCESS ))if (acc & (MAY_WRITE |MAY_SATTR |MAY_TRUNC )) { -if (EX_RDONLY (exp) ||IS_RDONLY (inode)) +if (EX_RDONLY (exp) ||IS_RDONLY_INODE (inode))return nfserr_rofs;if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE (inode))return nfserr_perm;
fs/ntfs/inode.c +2 -2
@@ -885,7 +885,7 @@ skip_large_dir_stuff:/* Everyone gets read and scan permissions. */ vi->i_mode |=S_IRUGO |S_IXUGO ;/* If not read-only, set write permissions. */ -if (!IS_RDONLY (vi)) +if (!IS_RDONLY_INODE (vi)) vi->i_mode |=S_IWUGO ;/* * Apply the directory permissions mask set in the mount
@@ -1026,7 +1026,7 @@ no_data_attr_special_case:/* Everyone gets all permissions. */ vi->i_mode |=S_IRWXUGO ;/* If read-only, noone gets write permissions. */ -if (IS_RDONLY (vi)) +if (IS_RDONLY_INODE (vi)) vi->i_mode &= ~S_IWUGO ;/* Apply the file permissions mask set in the mount options. */ vi->i_mode &= ~vol->fmask;
fs/fat/file.c +1 -1
@@ -90,7 +90,7 @@ void fat_truncate(struct inode *inode)int nr_clusters;/* Why no return value? Surely the disk could fail... */ -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))return /* -EPERM */ ;if (IS_IMMUTABLE (inode))return /* -EPERM */ ;
fs/jfs/xattr.c +1 -1
@@ -717,7 +717,7 @@ static int can_set_system_xattr(struct istatic int can_set_xattr (struct inode *inode,const char *name,const void *value,size_t value_len) { -if (IS_RDONLY (inode)) +if (IS_RDONLY_INODE (inode))return -EROFS ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode) ||S_ISLNK (inode->i_mode))
fs/ext3/inode.c +1 -1
@@ -3018,7 +3018,7 @@ int ext3_change_inode_journal_flag(struc*/ journal =EXT3_JOURNAL (inode); -if (is_journal_aborted (journal) ||IS_RDONLY (inode)) +if (is_journal_aborted (journal) ||IS_RDONLY_INODE (inode))return -EROFS ;journal_lock_updates (journal);
fs/ncpfs/file.c +1 -1
@@ -175,7 +175,7 @@ ncp_file_read(struct file *file, char *b *ppos = pos; -if (!IS_RDONLY (inode)) { +if (!IS_RDONLY_INODE (inode)) { inode->i_atime =CURRENT_TIME ; }
fs/ncpfs/mmap.c +1 -1
@@ -123,7 +123,7 @@ int ncp_mmap(struct file *file, struct vif (((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff > (1U << (32 -PAGE_SHIFT )))return -EFBIG ; -if (!IS_RDONLY (inode)) { +if (!IS_RDONLY_INODE (inode)) { inode->i_atime =CURRENT_TIME ; }
On Monday 15 March 2004 05:14, Andrew Morton wrote:
Hi Herbert, Andrew,
Quoted 7 lines
Quoted 2 lines · Herbert Poetzl
; this patch adds some functionality to the --bind ; type of vfs mounts.
This won't apply any more. We very recently changed a large number of filesystems to not call
update_atime()from within their readdir functions. That operation was hoisted up tovfs_readdir().
right. Anyway, I like to see this merged into -mm for wider testing after Herbert has fixed up some things like update_atime removal etc.
I personally use it for a long time now and I really like it.
ciao, Marc
Quoted 1 line
I personally use it for a long time now and I really like it.
Same here, I hope this functionality gets merged sooner rather then later.
Signature · 2 lines
Dariush Pietrzak, Key fingerprint = 40D0 9FFB 9939 7320 8294 05E0 BCC7 02C4 75CC 50D9