aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-06-23 05:05:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:43:02 -0400
commit75e1fcc0b18df0a65ab113198e9dc0e98999a08c (patch)
tree3ac0d0d3120cbca4ee9734494e2c9a4e0775ac4f
parentff7b86b82083f24b8637dff1528c7101c18c7f39 (diff)
[PATCH] vfs: add lock owner argument to flush operation
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>
-rw-r--r--arch/ia64/kernel/perfmon.c3
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/scsi/osst.c2
-rw-r--r--drivers/scsi/st.c2
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/file.c2
-rw-r--r--fs/coda/file.c2
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/locks.c2
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/open.c2
-rw-r--r--include/linux/coda_linux.h2
-rw-r--r--include/linux/fs.h3
-rw-r--r--ipc/mqueue.c2
14 files changed, 16 insertions, 16 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 2359e2809f50..6d7bc8ff7b3a 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -532,7 +532,6 @@ static ctl_table pfm_sysctl_root[] = {
532static struct ctl_table_header *pfm_sysctl_header; 532static struct ctl_table_header *pfm_sysctl_header;
533 533
534static int pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs); 534static int pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
535static int pfm_flush(struct file *filp);
536 535
537#define pfm_get_cpu_var(v) __ia64_per_cpu_var(v) 536#define pfm_get_cpu_var(v) __ia64_per_cpu_var(v)
538#define pfm_get_cpu_data(a,b) per_cpu(a, b) 537#define pfm_get_cpu_data(a,b) per_cpu(a, b)
@@ -1774,7 +1773,7 @@ pfm_syswide_cleanup_other_cpu(pfm_context_t *ctx)
1774 * When caller is self-monitoring, the context is unloaded. 1773 * When caller is self-monitoring, the context is unloaded.
1775 */ 1774 */
1776static int 1775static int
1777pfm_flush(struct file *filp) 1776pfm_flush(struct file *filp, fl_owner_t id)
1778{ 1777{
1779 pfm_context_t *ctx; 1778 pfm_context_t *ctx;
1780 struct task_struct *task; 1779 struct task_struct *task;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index ba325f16d077..5f561fce32d8 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -82,7 +82,7 @@ static int evdev_fasync(int fd, struct file *file, int on)
82 return retval < 0 ? retval : 0; 82 return retval < 0 ? retval : 0;
83} 83}
84 84
85static int evdev_flush(struct file * file) 85static int evdev_flush(struct file * file, fl_owner_t id)
86{ 86{
87 struct evdev_list *list = file->private_data; 87 struct evdev_list *list = file->private_data;
88 if (!list->evdev->exist) return -ENODEV; 88 if (!list->evdev->exist) return -ENODEV;
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index ce0ba3a174f9..4a2fed350d4e 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -4724,7 +4724,7 @@ err_out:
4724 4724
4725 4725
4726/* Flush the tape buffer before close */ 4726/* Flush the tape buffer before close */
4727static int os_scsi_tape_flush(struct file * filp) 4727static int os_scsi_tape_flush(struct file * filp, fl_owner_t id)
4728{ 4728{
4729 int result = 0, result2; 4729 int result = 0, result2;
4730 struct osst_tape * STp = filp->private_data; 4730 struct osst_tape * STp = filp->private_data;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index ad87d73f88ee..1272dd249af3 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1193,7 +1193,7 @@ static int st_open(struct inode *inode, struct file *filp)
1193 1193
1194 1194
1195/* Flush the tape buffer before close */ 1195/* Flush the tape buffer before close */
1196static int st_flush(struct file *filp) 1196static int st_flush(struct file *filp, fl_owner_t id)
1197{ 1197{
1198 int result = 0, result2; 1198 int result = 0, result2;
1199 unsigned char cmd[MAX_COMMAND_SIZE]; 1199 unsigned char cmd[MAX_COMMAND_SIZE];
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index c98755dca868..d56c0577c710 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -74,7 +74,7 @@ extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,
74 size_t write_size, loff_t * poffset); 74 size_t write_size, loff_t * poffset);
75extern int cifs_lock(struct file *, int, struct file_lock *); 75extern int cifs_lock(struct file *, int, struct file_lock *);
76extern int cifs_fsync(struct file *, struct dentry *, int); 76extern int cifs_fsync(struct file *, struct dentry *, int);
77extern int cifs_flush(struct file *); 77extern int cifs_flush(struct file *, fl_owner_t id);
78extern int cifs_file_mmap(struct file * , struct vm_area_struct *); 78extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
79extern const struct file_operations cifs_dir_ops; 79extern const struct file_operations cifs_dir_ops;
80extern int cifs_dir_open(struct inode *inode, struct file *file); 80extern int cifs_dir_open(struct inode *inode, struct file *file);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 487ea8b3baaa..b4a18c1cab0a 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1417,7 +1417,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
1417 * As file closes, flush all cached write data for this inode checking 1417 * As file closes, flush all cached write data for this inode checking
1418 * for write behind errors. 1418 * for write behind errors.
1419 */ 1419 */
1420int cifs_flush(struct file *file) 1420int cifs_flush(struct file *file, fl_owner_t id)
1421{ 1421{
1422 struct inode * inode = file->f_dentry->d_inode; 1422 struct inode * inode = file->f_dentry->d_inode;
1423 int rc = 0; 1423 int rc = 0;
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 7c2642431fa5..cc66c681bd11 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -164,7 +164,7 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
164 return 0; 164 return 0;
165} 165}
166 166
167int coda_flush(struct file *coda_file) 167int coda_flush(struct file *coda_file, fl_owner_t id)
168{ 168{
169 unsigned short flags = coda_file->f_flags & ~O_EXCL; 169 unsigned short flags = coda_file->f_flags & ~O_EXCL;
170 unsigned short coda_flags = coda_flags_to_cflags(flags); 170 unsigned short coda_flags = coda_flags_to_cflags(flags);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index fc342cf7c2cc..087f3b734f40 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -169,7 +169,7 @@ static int fuse_release(struct inode *inode, struct file *file)
169 return fuse_release_common(inode, file, 0); 169 return fuse_release_common(inode, file, 0);
170} 170}
171 171
172static int fuse_flush(struct file *file) 172static int fuse_flush(struct file *file, fl_owner_t id)
173{ 173{
174 struct inode *inode = file->f_dentry->d_inode; 174 struct inode *inode = file->f_dentry->d_inode;
175 struct fuse_conn *fc = get_fuse_conn(inode); 175 struct fuse_conn *fc = get_fuse_conn(inode);
diff --git a/fs/locks.c b/fs/locks.c
index e588e1c265f7..f8a634ac1121 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1907,7 +1907,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
1907 return; 1907 return;
1908 1908
1909 lock.fl_type = F_UNLCK; 1909 lock.fl_type = F_UNLCK;
1910 lock.fl_flags = FL_POSIX; 1910 lock.fl_flags = FL_POSIX | FL_CLOSE;
1911 lock.fl_start = 0; 1911 lock.fl_start = 0;
1912 lock.fl_end = OFFSET_MAX; 1912 lock.fl_end = OFFSET_MAX;
1913 lock.fl_owner = owner; 1913 lock.fl_owner = owner;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index fade02c15e6e..fa05c027ea11 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -43,7 +43,7 @@ static int nfs_file_mmap(struct file *, struct vm_area_struct *);
43static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); 43static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
44static ssize_t nfs_file_read(struct kiocb *, char __user *, size_t, loff_t); 44static ssize_t nfs_file_read(struct kiocb *, char __user *, size_t, loff_t);
45static ssize_t nfs_file_write(struct kiocb *, const char __user *, size_t, loff_t); 45static ssize_t nfs_file_write(struct kiocb *, const char __user *, size_t, loff_t);
46static int nfs_file_flush(struct file *); 46static int nfs_file_flush(struct file *, fl_owner_t id);
47static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); 47static int nfs_fsync(struct file *, struct dentry *dentry, int datasync);
48static int nfs_check_flags(int flags); 48static int nfs_check_flags(int flags);
49static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); 49static 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)
188 * 188 *
189 */ 189 */
190static int 190static int
191nfs_file_flush(struct file *file) 191nfs_file_flush(struct file *file, fl_owner_t id)
192{ 192{
193 struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; 193 struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data;
194 struct inode *inode = file->f_dentry->d_inode; 194 struct inode *inode = file->f_dentry->d_inode;
diff --git a/fs/open.c b/fs/open.c
index a37ff861108f..5fb16e5267dc 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1152,7 +1152,7 @@ int filp_close(struct file *filp, fl_owner_t id)
1152 } 1152 }
1153 1153
1154 if (filp->f_op && filp->f_op->flush) 1154 if (filp->f_op && filp->f_op->flush)
1155 retval = filp->f_op->flush(filp); 1155 retval = filp->f_op->flush(filp, id);
1156 1156
1157 dnotify_flush(filp, id); 1157 dnotify_flush(filp, id);
1158 locks_remove_posix(filp, id); 1158 locks_remove_posix(filp, id);
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index b3ecf8f71d97..7b5c5df5cb69 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -36,7 +36,7 @@ extern const struct file_operations coda_ioctl_operations;
36 36
37/* operations shared over more than one file */ 37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f); 38int coda_open(struct inode *i, struct file *f);
39int coda_flush(struct file *f); 39int coda_flush(struct file *f, fl_owner_t id);
40int coda_release(struct inode *i, struct file *f); 40int coda_release(struct inode *i, struct file *f);
41int coda_permission(struct inode *inode, int mask, struct nameidata *nd); 41int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
42int coda_revalidate_inode(struct dentry *); 42int coda_revalidate_inode(struct dentry *);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e917403f4d58..56d8bf0d0a77 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -683,6 +683,7 @@ extern spinlock_t files_lock;
683#define FL_FLOCK 2 683#define FL_FLOCK 2
684#define FL_ACCESS 8 /* not trying to lock, just looking */ 684#define FL_ACCESS 8 /* not trying to lock, just looking */
685#define FL_LEASE 32 /* lease held on this file */ 685#define FL_LEASE 32 /* lease held on this file */
686#define FL_CLOSE 64 /* unlock on close */
686#define FL_SLEEP 128 /* A blocking lock */ 687#define FL_SLEEP 128 /* A blocking lock */
687 688
688/* 689/*
@@ -1025,7 +1026,7 @@ struct file_operations {
1025 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1026 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1026 int (*mmap) (struct file *, struct vm_area_struct *); 1027 int (*mmap) (struct file *, struct vm_area_struct *);
1027 int (*open) (struct inode *, struct file *); 1028 int (*open) (struct inode *, struct file *);
1028 int (*flush) (struct file *); 1029 int (*flush) (struct file *, fl_owner_t id);
1029 int (*release) (struct inode *, struct file *); 1030 int (*release) (struct inode *, struct file *);
1030 int (*fsync) (struct file *, struct dentry *, int datasync); 1031 int (*fsync) (struct file *, struct dentry *, int datasync);
1031 int (*aio_fsync) (struct kiocb *, int datasync); 1032 int (*aio_fsync) (struct kiocb *, int datasync);
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 0a2a24b6ebe4..02e6f6798972 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -359,7 +359,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
359 return count; 359 return count;
360} 360}
361 361
362static int mqueue_flush_file(struct file *filp) 362static int mqueue_flush_file(struct file *filp, fl_owner_t id)
363{ 363{
364 struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode); 364 struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);
365 365