]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] vfs: add lock owner argument to flush operation
authorMiklos Szeredi <miklos@szeredi.hu>
Fri, 23 Jun 2006 09:05:12 +0000 (02:05 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 23 Jun 2006 14:43:02 +0000 (07:43 -0700)
Pass the POSIX lock owner ID to the flush operation.

This is useful for filesystems which don't want to store any locking state
in inode->i_flock but want to handle locking/unlocking POSIX locks
internally.  FUSE is one such filesystem but I think it possible that some
network filesystems would need this also.

Also add a flag to indicate that a POSIX locking request was generated by
close(), so filesystems using the above feature won't send an extra locking
request in this case.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
14 files changed:
arch/ia64/kernel/perfmon.c
drivers/input/evdev.c
drivers/scsi/osst.c
drivers/scsi/st.c
fs/cifs/cifsfs.h
fs/cifs/file.c
fs/coda/file.c
fs/fuse/file.c
fs/locks.c
fs/nfs/file.c
fs/open.c
include/linux/coda_linux.h
include/linux/fs.h
ipc/mqueue.c

index 2359e2809f506e65e786f525735d5b1c6d0ec013..6d7bc8ff7b3afff19b3781cdaa91a18d27268772 100644 (file)
@@ -532,7 +532,6 @@ static ctl_table pfm_sysctl_root[] = {
 static struct ctl_table_header *pfm_sysctl_header;
 
 static int pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
-static int pfm_flush(struct file *filp);
 
 #define pfm_get_cpu_var(v)             __ia64_per_cpu_var(v)
 #define pfm_get_cpu_data(a,b)          per_cpu(a, b)
@@ -1774,7 +1773,7 @@ pfm_syswide_cleanup_other_cpu(pfm_context_t *ctx)
  * When caller is self-monitoring, the context is unloaded.
  */
 static int
-pfm_flush(struct file *filp)
+pfm_flush(struct file *filp, fl_owner_t id)
 {
        pfm_context_t *ctx;
        struct task_struct *task;
index ba325f16d07796ede832c45cb81591eb3ee3b788..5f561fce32d843406ebd285cdedab1fc6586fcee 100644 (file)
@@ -82,7 +82,7 @@ static int evdev_fasync(int fd, struct file *file, int on)
        return retval < 0 ? retval : 0;
 }
 
-static int evdev_flush(struct file * file)
+static int evdev_flush(struct file * file, fl_owner_t id)
 {
        struct evdev_list *list = file->private_data;
        if (!list->evdev->exist) return -ENODEV;
index ce0ba3a174f9fc3632efbb42eb010dac69ed6278..4a2fed350d4e21620b134d2afac1244cb87670e0 100644 (file)
@@ -4724,7 +4724,7 @@ err_out:
 
 
 /* Flush the tape buffer before close */
-static int os_scsi_tape_flush(struct file * filp)
+static int os_scsi_tape_flush(struct file * filp, fl_owner_t id)
 {
        int                   result = 0, result2;
        struct osst_tape    * STp    = filp->private_data;
index ad87d73f88ee453f45d49c7644690c4ff807898d..1272dd249af314f7906478af35dac1770295996f 100644 (file)
@@ -1193,7 +1193,7 @@ static int st_open(struct inode *inode, struct file *filp)
 \f
 
 /* Flush the tape buffer before close */
-static int st_flush(struct file *filp)
+static int st_flush(struct file *filp, fl_owner_t id)
 {
        int result = 0, result2;
        unsigned char cmd[MAX_COMMAND_SIZE];
index c98755dca868743c25822124c1bc06d8b225a9ed..d56c0577c7103f95f1c8cd8068f1318cb45ab0cf 100644 (file)
@@ -74,7 +74,7 @@ extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,
                         size_t write_size, loff_t * poffset);
 extern int cifs_lock(struct file *, int, struct file_lock *);
 extern int cifs_fsync(struct file *, struct dentry *, int);
-extern int cifs_flush(struct file *);
+extern int cifs_flush(struct file *, fl_owner_t id);
 extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
 extern const struct file_operations cifs_dir_ops;
 extern int cifs_dir_open(struct inode *inode, struct file *file);
index 487ea8b3baaa4f512db3b802b7329e79a7f94d00..b4a18c1cab0a878dca81359c032a8f8b7f2bf83b 100644 (file)
@@ -1417,7 +1417,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
  * As file closes, flush all cached write data for this inode checking
  * for write behind errors.
  */
-int cifs_flush(struct file *file)
+int cifs_flush(struct file *file, fl_owner_t id)
 {
        struct inode * inode = file->f_dentry->d_inode;
        int rc = 0;
index 7c2642431fa5baa7bef2aa4cb0514b01615d5d0b..cc66c681bd11069d993f086db77198f8ba978dfb 100644 (file)
@@ -164,7 +164,7 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
        return 0;
 }
 
-int coda_flush(struct file *coda_file)
+int coda_flush(struct file *coda_file, fl_owner_t id)
 {
        unsigned short flags = coda_file->f_flags & ~O_EXCL;
        unsigned short coda_flags = coda_flags_to_cflags(flags);
index fc342cf7c2cc7881dbfafa09097d6de52b34bdca..087f3b734f407a5d072b72cc375eb722d351a9ae 100644 (file)
@@ -169,7 +169,7 @@ static int fuse_release(struct inode *inode, struct file *file)
        return fuse_release_common(inode, file, 0);
 }
 
-static int fuse_flush(struct file *file)
+static int fuse_flush(struct file *file, fl_owner_t id)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
index e588e1c265f76a3c1acf3b4a10408d357dbe8525..f8a634ac11217ee5e88ea50cdd1c7c68eb45cd7d 100644 (file)
@@ -1907,7 +1907,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
                return;
 
        lock.fl_type = F_UNLCK;
-       lock.fl_flags = FL_POSIX;
+       lock.fl_flags = FL_POSIX | FL_CLOSE;
        lock.fl_start = 0;
        lock.fl_end = OFFSET_MAX;
        lock.fl_owner = owner;
index fade02c15e6ef11a8575e6381b6f10445a1de375..fa05c027ea11f9e1e6f10612e2075ca002858d6a 100644 (file)
@@ -43,7 +43,7 @@ static int  nfs_file_mmap(struct file *, struct vm_area_struct *);
 static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
 static ssize_t nfs_file_read(struct kiocb *, char __user *, size_t, loff_t);
 static ssize_t nfs_file_write(struct kiocb *, const char __user *, size_t, loff_t);
-static int  nfs_file_flush(struct file *);
+static int  nfs_file_flush(struct file *, fl_owner_t id);
 static int  nfs_fsync(struct file *, struct dentry *dentry, int datasync);
 static int nfs_check_flags(int flags);
 static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl);
@@ -188,7 +188,7 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
  *
  */
 static int
-nfs_file_flush(struct file *file)
+nfs_file_flush(struct file *file, fl_owner_t id)
 {
        struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data;
        struct inode    *inode = file->f_dentry->d_inode;
index a37ff861108f93222cbf12d4e19269e8d71555c0..5fb16e5267dc253b16ffaf89e875aebcbc3c9739 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -1152,7 +1152,7 @@ int filp_close(struct file *filp, fl_owner_t id)
        }
 
        if (filp->f_op && filp->f_op->flush)
-               retval = filp->f_op->flush(filp);
+               retval = filp->f_op->flush(filp, id);
 
        dnotify_flush(filp, id);
        locks_remove_posix(filp, id);
index b3ecf8f71d97066666ed60cdef837e4bdd436b0f..7b5c5df5cb69213ab7c2b5e45f1939c2b2ddc8b5 100644 (file)
@@ -36,7 +36,7 @@ extern const struct file_operations coda_ioctl_operations;
 
 /* operations shared over more than one file */
 int coda_open(struct inode *i, struct file *f);
-int coda_flush(struct file *f);
+int coda_flush(struct file *f, fl_owner_t id);
 int coda_release(struct inode *i, struct file *f);
 int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
 int coda_revalidate_inode(struct dentry *);
index e917403f4d58fdaa64282db6204e49db0e2808db..56d8bf0d0a77ed36d14c1a23a9384f12b3ee91f8 100644 (file)
@@ -683,6 +683,7 @@ extern spinlock_t files_lock;
 #define FL_FLOCK       2
 #define FL_ACCESS      8       /* not trying to lock, just looking */
 #define FL_LEASE       32      /* lease held on this file */
+#define FL_CLOSE       64      /* unlock on close */
 #define FL_SLEEP       128     /* A blocking lock */
 
 /*
@@ -1025,7 +1026,7 @@ struct file_operations {
        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
        int (*mmap) (struct file *, struct vm_area_struct *);
        int (*open) (struct inode *, struct file *);
-       int (*flush) (struct file *);
+       int (*flush) (struct file *, fl_owner_t id);
        int (*release) (struct inode *, struct file *);
        int (*fsync) (struct file *, struct dentry *, int datasync);
        int (*aio_fsync) (struct kiocb *, int datasync);
index 0a2a24b6ebe40b3ff143ea0dfcaa5ae67ebba040..02e6f679897282d4d16c73ed70ccb9f5e98857e5 100644 (file)
@@ -359,7 +359,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
        return count;
 }
 
-static int mqueue_flush_file(struct file *filp)
+static int mqueue_flush_file(struct file *filp, fl_owner_t id)
 {
        struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);