* [patch 0/5] vfs: cleanups
@ 2008-06-24 14:50 Miklos Szeredi
2008-06-24 14:50 ` [patch 1/5] vfs: truncate: dont check immutable twice Miklos Szeredi
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm
Al,
Could you please take these VFS cleanups for 2.6.27?
Thanks,
Miklos
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 1/5] vfs: truncate: dont check immutable twice
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
@ 2008-06-24 14:50 ` Miklos Szeredi
2008-06-24 14:50 ` [patch 2/5] vfs: create file_truncate() helper Miklos Szeredi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm
[-- Attachment #1: vfs-truncate-dont-check-immutable-twice.patch --]
[-- Type: text/plain, Size: 787 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
vfs_permission(MAY_WRITE) already checked for the inode being
immutable, so no need to repeat it.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Acked-by: Christoph Hellwig <hch@infradead.org>
---
fs/open.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6/fs/open.c
===================================================================
--- linux-2.6.orig/fs/open.c 2008-06-11 10:16:13.000000000 +0200
+++ linux-2.6/fs/open.c 2008-06-13 13:15:01.000000000 +0200
@@ -254,7 +254,7 @@ static long do_sys_truncate(const char _
goto mnt_drop_write_and_out;
error = -EPERM;
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+ if (IS_APPEND(inode))
goto mnt_drop_write_and_out;
error = get_write_access(inode);
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 2/5] vfs: create file_truncate() helper
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
2008-06-24 14:50 ` [patch 1/5] vfs: truncate: dont check immutable twice Miklos Szeredi
@ 2008-06-24 14:50 ` Miklos Szeredi
2008-06-24 14:50 ` [patch 3/5] vfs: change remove_suid() to file_remove_suid() Miklos Szeredi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm
[-- Attachment #1: vfs-create-file_truncate-helper.patch --]
[-- Type: text/plain, Size: 4064 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Clean up do_truncate() API:
- create a new function file_truncate()
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/exec.c | 2 +-
fs/open.c | 24 ++++++++++++++++++++----
include/linux/fs.h | 2 ++
mm/tiny-shmem.c | 2 +-
4 files changed, 24 insertions(+), 6 deletions(-)
Index: linux-2.6/fs/exec.c
===================================================================
--- linux-2.6.orig/fs/exec.c 2008-06-19 14:58:09.000000000 +0200
+++ linux-2.6/fs/exec.c 2008-06-24 16:24:46.000000000 +0200
@@ -1772,7 +1772,7 @@ int do_coredump(long signr, int exit_cod
goto close_fail;
if (!file->f_op->write)
goto close_fail;
- if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
+ if (!ispipe && file_truncate(file, 0, 0) != 0)
goto close_fail;
retval = binfmt->core_dump(signr, regs, file, core_limit);
Index: linux-2.6/fs/open.c
===================================================================
--- linux-2.6.orig/fs/open.c 2008-06-24 16:24:40.000000000 +0200
+++ linux-2.6/fs/open.c 2008-06-24 16:24:46.000000000 +0200
@@ -195,6 +195,13 @@ out:
return error;
}
+/*
+ * do_truncate - truncate (or extend) an inode
+ * @dentry: the dentry to truncate
+ * @length: the new length
+ * @time_attrs: file times to be updated (e.g. ATTR_MTIME|ATTR_CTIME)
+ * @filp: an open file or NULL (see file_truncate() as well)
+ */
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
struct file *filp)
{
@@ -221,6 +228,17 @@ int do_truncate(struct dentry *dentry, l
return err;
}
+/*
+ * file_truncate - truncate (or extend) an open file
+ * @filp: the open file
+ * @length: the new length
+ * @time_attrs: file times to be updated (e.g. ATTR_MTIME|ATTR_CTIME)
+ */
+int file_truncate(struct file *filp, loff_t length, unsigned int time_attrs)
+{
+ return do_truncate(filp->f_path.dentry, length, time_attrs, filp);
+}
+
static long do_sys_truncate(const char __user * path, loff_t length)
{
struct nameidata nd;
@@ -294,7 +312,6 @@ asmlinkage long sys_truncate(const char
static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
{
struct inode * inode;
- struct dentry *dentry;
struct file * file;
int error;
@@ -310,8 +327,7 @@ static long do_sys_ftruncate(unsigned in
if (file->f_flags & O_LARGEFILE)
small = 0;
- dentry = file->f_path.dentry;
- inode = dentry->d_inode;
+ inode = file->f_path.dentry->d_inode;
error = -EINVAL;
if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
goto out_putf;
@@ -327,7 +343,7 @@ static long do_sys_ftruncate(unsigned in
error = locks_verify_truncate(inode, file, length);
if (!error)
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
+ error = file_truncate(file, length, ATTR_MTIME|ATTR_CTIME);
out_putf:
fput(file);
out:
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h 2008-06-24 16:13:32.000000000 +0200
+++ linux-2.6/include/linux/fs.h 2008-06-24 16:24:46.000000000 +0200
@@ -1598,6 +1598,8 @@ static inline int break_lease(struct ino
extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
struct file *filp);
+extern int file_truncate(struct file *filp, loff_t start,
+ unsigned int time_attrs);
extern long do_sys_open(int dfd, const char __user *filename, int flags,
int mode);
extern struct file *filp_open(const char *, int, int);
Index: linux-2.6/mm/tiny-shmem.c
===================================================================
--- linux-2.6.orig/mm/tiny-shmem.c 2008-06-19 14:58:13.000000000 +0200
+++ linux-2.6/mm/tiny-shmem.c 2008-06-24 16:24:46.000000000 +0200
@@ -80,7 +80,7 @@ struct file *shmem_file_setup(char *name
inode->i_nlink = 0; /* It is unlinked */
/* notify everyone as to the change of file size */
- error = do_truncate(dentry, size, 0, file);
+ error = file_truncate(file, size, 0);
if (error < 0)
goto close_file;
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 3/5] vfs: change remove_suid() to file_remove_suid()
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
2008-06-24 14:50 ` [patch 1/5] vfs: truncate: dont check immutable twice Miklos Szeredi
2008-06-24 14:50 ` [patch 2/5] vfs: create file_truncate() helper Miklos Szeredi
@ 2008-06-24 14:50 ` Miklos Szeredi
2008-06-24 14:50 ` [patch 4/5] vfs: reuse local variable in vfs_link() Miklos Szeredi
2008-06-24 14:50 ` [patch 5/5] vfs: remove mode parameter from vfs_symlink() Miklos Szeredi
4 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm
[-- Attachment #1: vfs-change-remove_suid-to-file_remove_suid.patch --]
[-- Type: text/plain, Size: 4948 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
All calls to remove_suid() are made with a file pointer, because
(similarly to file_update_time) it is called when the file is written.
Clean up callers by passing in a file instead of a dentry.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/fuse/file.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/splice.c | 4 ++--
fs/xfs/linux-2.6/xfs_lrw.c | 2 +-
include/linux/fs.h | 2 +-
mm/filemap.c | 7 ++++---
mm/filemap_xip.c | 2 +-
7 files changed, 11 insertions(+), 10 deletions(-)
Index: linux-2.6/fs/fuse/file.c
===================================================================
--- linux-2.6.orig/fs/fuse/file.c 2008-06-21 10:18:52.000000000 +0200
+++ linux-2.6/fs/fuse/file.c 2008-06-24 16:25:25.000000000 +0200
@@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struc
if (count == 0)
goto out;
- err = remove_suid(file->f_path.dentry);
+ err = file_remove_suid(file);
if (err)
goto out;
Index: linux-2.6/fs/ntfs/file.c
===================================================================
--- linux-2.6.orig/fs/ntfs/file.c 2008-06-19 14:58:10.000000000 +0200
+++ linux-2.6/fs/ntfs/file.c 2008-06-24 16:25:25.000000000 +0200
@@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_noloc
goto out;
if (!count)
goto out;
- err = remove_suid(file->f_path.dentry);
+ err = file_remove_suid(file);
if (err)
goto out;
file_update_time(file);
Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c 2008-06-24 13:58:36.000000000 +0200
+++ linux-2.6/fs/splice.c 2008-06-24 16:25:25.000000000 +0200
@@ -763,7 +763,7 @@ generic_file_splice_write_nolock(struct
ssize_t ret;
int err;
- err = remove_suid(out->f_path.dentry);
+ err = file_remove_suid(out);
if (unlikely(err))
return err;
@@ -821,7 +821,7 @@ generic_file_splice_write(struct pipe_in
ssize_t ret;
inode_double_lock(inode, pipe->inode);
- ret = remove_suid(out->f_path.dentry);
+ ret = file_remove_suid(out);
if (likely(!ret))
ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
inode_double_unlock(inode, pipe->inode);
Index: linux-2.6/fs/xfs/linux-2.6/xfs_lrw.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_lrw.c 2008-06-19 14:58:11.000000000 +0200
+++ linux-2.6/fs/xfs/linux-2.6/xfs_lrw.c 2008-06-24 16:25:25.000000000 +0200
@@ -711,7 +711,7 @@ start:
!capable(CAP_FSETID)) {
error = xfs_write_clear_setuid(xip);
if (likely(!error))
- error = -remove_suid(file->f_path.dentry);
+ error = -file_remove_suid(file);
if (unlikely(error)) {
goto out_unlock_internal;
}
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h 2008-06-24 16:24:46.000000000 +0200
+++ linux-2.6/include/linux/fs.h 2008-06-24 16:25:25.000000000 +0200
@@ -1817,7 +1817,7 @@ extern void clear_inode(struct inode *);
extern void destroy_inode(struct inode *);
extern struct inode *new_inode(struct super_block *);
extern int should_remove_suid(struct dentry *);
-extern int remove_suid(struct dentry *);
+extern int file_remove_suid(struct file *);
extern void __insert_inode_hash(struct inode *, unsigned long hashval);
extern void remove_inode_hash(struct inode *);
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c 2008-06-24 13:58:36.000000000 +0200
+++ linux-2.6/mm/filemap.c 2008-06-24 16:25:25.000000000 +0200
@@ -1668,8 +1668,9 @@ static int __remove_suid(struct dentry *
return notify_change(dentry, &newattrs);
}
-int remove_suid(struct dentry *dentry)
+int file_remove_suid(struct file *file)
{
+ struct dentry *dentry = file->f_path.dentry;
int killsuid = should_remove_suid(dentry);
int killpriv = security_inode_need_killpriv(dentry);
int error = 0;
@@ -1683,7 +1684,7 @@ int remove_suid(struct dentry *dentry)
return error;
}
-EXPORT_SYMBOL(remove_suid);
+EXPORT_SYMBOL(file_remove_suid);
static size_t __iovec_copy_from_user_inatomic(char *vaddr,
const struct iovec *iov, size_t base, size_t bytes)
@@ -2394,7 +2395,7 @@ __generic_file_aio_write_nolock(struct k
if (count == 0)
goto out;
- err = remove_suid(file->f_path.dentry);
+ err = file_remove_suid(file);
if (err)
goto out;
Index: linux-2.6/mm/filemap_xip.c
===================================================================
--- linux-2.6.orig/mm/filemap_xip.c 2008-06-19 14:58:13.000000000 +0200
+++ linux-2.6/mm/filemap_xip.c 2008-06-24 16:25:25.000000000 +0200
@@ -380,7 +380,7 @@ xip_file_write(struct file *filp, const
if (count == 0)
goto out_backing;
- ret = remove_suid(filp->f_path.dentry);
+ ret = file_remove_suid(filp);
if (ret)
goto out_backing;
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 4/5] vfs: reuse local variable in vfs_link()
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
` (2 preceding siblings ...)
2008-06-24 14:50 ` [patch 3/5] vfs: change remove_suid() to file_remove_suid() Miklos Szeredi
@ 2008-06-24 14:50 ` Miklos Szeredi
2008-06-24 14:50 ` [patch 5/5] vfs: remove mode parameter from vfs_symlink() Miklos Szeredi
4 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm, Tetsuo Handa
[-- Attachment #1: vfs-reuse-local-variable-in-vfs_link.patch --]
[-- Type: text/plain, Size: 1293 bytes --]
From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Why not reuse "inode" which is assigned as
struct inode *inode = old_dentry->d_inode;
in the beginning of vfs_link() ?
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namei.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c 2008-06-24 16:13:32.000000000 +0200
+++ linux-2.6/fs/namei.c 2008-06-24 16:26:00.000000000 +0200
@@ -2498,19 +2498,19 @@ int vfs_link(struct dentry *old_dentry,
return -EPERM;
if (!dir->i_op || !dir->i_op->link)
return -EPERM;
- if (S_ISDIR(old_dentry->d_inode->i_mode))
+ if (S_ISDIR(inode->i_mode))
return -EPERM;
error = security_inode_link(old_dentry, dir, new_dentry);
if (error)
return error;
- mutex_lock(&old_dentry->d_inode->i_mutex);
+ mutex_lock(&inode->i_mutex);
DQUOT_INIT(dir);
error = dir->i_op->link(old_dentry, dir, new_dentry);
- mutex_unlock(&old_dentry->d_inode->i_mutex);
+ mutex_unlock(&inode->i_mutex);
if (!error)
- fsnotify_link(dir, old_dentry->d_inode, new_dentry);
+ fsnotify_link(dir, inode, new_dentry);
return error;
}
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 5/5] vfs: remove mode parameter from vfs_symlink()
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
` (3 preceding siblings ...)
2008-06-24 14:50 ` [patch 4/5] vfs: reuse local variable in vfs_link() Miklos Szeredi
@ 2008-06-24 14:50 ` Miklos Szeredi
4 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2008-06-24 14:50 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, hch, akpm, Tetsuo Handa
[-- Attachment #1: vfs-remove-mode-parameter-from-path_symlink.patch --]
[-- Type: text/plain, Size: 4548 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Remove the unused mode parameter from vfs_symlink and callers.
Thanks to Tetsuo Handa for noticing.
CC: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/ecryptfs/inode.c | 4 +---
fs/namei.c | 4 ++--
fs/nfsd/vfs.c | 10 ++--------
include/linux/fs.h | 2 +-
4 files changed, 6 insertions(+), 14 deletions(-)
Index: linux-2.6/fs/ecryptfs/inode.c
===================================================================
--- linux-2.6.orig/fs/ecryptfs/inode.c 2008-06-19 14:58:09.000000000 +0200
+++ linux-2.6/fs/ecryptfs/inode.c 2008-06-24 16:26:14.000000000 +0200
@@ -444,7 +444,6 @@ static int ecryptfs_symlink(struct inode
int rc;
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
- umode_t mode;
char *encoded_symname;
int encoded_symlen;
struct ecryptfs_crypt_stat *crypt_stat = NULL;
@@ -452,7 +451,6 @@ static int ecryptfs_symlink(struct inode
lower_dentry = ecryptfs_dentry_to_lower(dentry);
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
- mode = S_IALLUGO;
encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname,
strlen(symname),
&encoded_symname);
@@ -461,7 +459,7 @@ static int ecryptfs_symlink(struct inode
goto out_lock;
}
rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
- encoded_symname, mode);
+ encoded_symname);
kfree(encoded_symname);
if (rc || !lower_dentry->d_inode)
goto out_lock;
Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c 2008-06-24 16:26:00.000000000 +0200
+++ linux-2.6/fs/namei.c 2008-06-24 16:26:14.000000000 +0200
@@ -2408,7 +2408,7 @@ asmlinkage long sys_unlink(const char __
return do_unlinkat(AT_FDCWD, pathname);
}
-int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
+int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
{
int error = may_create(dir, dentry, NULL);
@@ -2457,7 +2457,7 @@ asmlinkage long sys_symlinkat(const char
error = mnt_want_write(nd.path.mnt);
if (error)
goto out_dput;
- error = vfs_symlink(nd.path.dentry->d_inode, dentry, from, S_IALLUGO);
+ error = vfs_symlink(nd.path.dentry->d_inode, dentry, from);
mnt_drop_write(nd.path.mnt);
out_dput:
dput(dentry);
Index: linux-2.6/fs/nfsd/vfs.c
===================================================================
--- linux-2.6.orig/fs/nfsd/vfs.c 2008-06-24 13:58:36.000000000 +0200
+++ linux-2.6/fs/nfsd/vfs.c 2008-06-24 16:26:14.000000000 +0200
@@ -1517,7 +1517,6 @@ nfsd_symlink(struct svc_rqst *rqstp, str
struct dentry *dentry, *dnew;
__be32 err, cerr;
int host_err;
- umode_t mode;
err = nfserr_noent;
if (!flen || !plen)
@@ -1536,11 +1535,6 @@ nfsd_symlink(struct svc_rqst *rqstp, str
if (IS_ERR(dnew))
goto out_nfserr;
- mode = S_IALLUGO;
- /* Only the MODE ATTRibute is even vaguely meaningful */
- if (iap && (iap->ia_valid & ATTR_MODE))
- mode = iap->ia_mode & S_IALLUGO;
-
host_err = mnt_want_write(fhp->fh_export->ex_path.mnt);
if (host_err)
goto out_nfserr;
@@ -1552,11 +1546,11 @@ nfsd_symlink(struct svc_rqst *rqstp, str
else {
strncpy(path_alloced, path, plen);
path_alloced[plen] = 0;
- host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
+ host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced);
kfree(path_alloced);
}
} else
- host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
+ host_err = vfs_symlink(dentry->d_inode, dnew, path);
if (!host_err) {
if (EX_ISSYNC(fhp->fh_export))
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h 2008-06-24 16:25:25.000000000 +0200
+++ linux-2.6/include/linux/fs.h 2008-06-24 16:26:14.000000000 +0200
@@ -1125,7 +1125,7 @@ extern int vfs_permission(struct nameida
extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
extern int vfs_mkdir(struct inode *, struct dentry *, int);
extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
-extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
+extern int vfs_symlink(struct inode *, struct dentry *, const char *);
extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
extern int vfs_rmdir(struct inode *, struct dentry *);
extern int vfs_unlink(struct inode *, struct dentry *);
--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-24 14:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 14:50 [patch 0/5] vfs: cleanups Miklos Szeredi
2008-06-24 14:50 ` [patch 1/5] vfs: truncate: dont check immutable twice Miklos Szeredi
2008-06-24 14:50 ` [patch 2/5] vfs: create file_truncate() helper Miklos Szeredi
2008-06-24 14:50 ` [patch 3/5] vfs: change remove_suid() to file_remove_suid() Miklos Szeredi
2008-06-24 14:50 ` [patch 4/5] vfs: reuse local variable in vfs_link() Miklos Szeredi
2008-06-24 14:50 ` [patch 5/5] vfs: remove mode parameter from vfs_symlink() Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®