aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWendy Cheng <wcheng@redhat.com>2007-11-29 17:56:51 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2008-01-25 03:08:15 -0500
commitc97bfe4351771675963e02f34d31e206fd2d7150 (patch)
tree9ee4de86cacc54f3e49135a4ce39cf7a236efb31 /fs
parentbcd405599faa16cf32a3d3f1ce6a1e12cb37fede (diff)
[GFS2] Remove lock methods for lock_nolock protocol
GFS2 supports two modes of locking - lock_nolock for single node filesystem and lock_dlm for cluster mode locking. The gfs2 lock methods are removed from file operation table for lock_nolock protocol. This would allow VFS to handle posix lock and flock logics just like other in-tree filesystems without duplication. Signed-off-by: S. Wendy Cheng <wcheng@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/inode.c11
-rw-r--r--fs/gfs2/ops_file.c36
-rw-r--r--fs/gfs2/ops_inode.h2
3 files changed, 35 insertions, 14 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 92959d093adf..53bca9978fb5 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -131,14 +131,21 @@ static struct inode *gfs2_iget_skip(struct super_block *sb,
131 131
132void gfs2_set_iop(struct inode *inode) 132void gfs2_set_iop(struct inode *inode)
133{ 133{
134 struct gfs2_sbd *sdp = GFS2_SB(inode);
134 umode_t mode = inode->i_mode; 135 umode_t mode = inode->i_mode;
135 136
136 if (S_ISREG(mode)) { 137 if (S_ISREG(mode)) {
137 inode->i_op = &gfs2_file_iops; 138 inode->i_op = &gfs2_file_iops;
138 inode->i_fop = &gfs2_file_fops; 139 if (sdp->sd_args.ar_localflocks)
140 inode->i_fop = &gfs2_file_fops_nolock;
141 else
142 inode->i_fop = &gfs2_file_fops;
139 } else if (S_ISDIR(mode)) { 143 } else if (S_ISDIR(mode)) {
140 inode->i_op = &gfs2_dir_iops; 144 inode->i_op = &gfs2_dir_iops;
141 inode->i_fop = &gfs2_dir_fops; 145 if (sdp->sd_args.ar_localflocks)
146 inode->i_fop = &gfs2_dir_fops_nolock;
147 else
148 inode->i_fop = &gfs2_dir_fops;
142 } else if (S_ISLNK(mode)) { 149 } else if (S_ISLNK(mode)) {
143 inode->i_op = &gfs2_symlink_iops; 150 inode->i_op = &gfs2_symlink_iops;
144 } else { 151 } else {
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index ad5daaa6babc..db76ac1947e7 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -615,15 +615,6 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
615 if (__mandatory_lock(&ip->i_inode)) 615 if (__mandatory_lock(&ip->i_inode))
616 return -ENOLCK; 616 return -ENOLCK;
617 617
618 if (sdp->sd_args.ar_localflocks) {
619 if (IS_GETLK(cmd)) {
620 posix_test_lock(file, fl);
621 return 0;
622 } else {
623 return posix_lock_file_wait(file, fl);
624 }
625 }
626
627 if (cmd == F_CANCELLK) { 618 if (cmd == F_CANCELLK) {
628 /* Hack: */ 619 /* Hack: */
629 cmd = F_SETLK; 620 cmd = F_SETLK;
@@ -716,9 +707,6 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
716 if (__mandatory_lock(&ip->i_inode)) 707 if (__mandatory_lock(&ip->i_inode))
717 return -ENOLCK; 708 return -ENOLCK;
718 709
719 if (sdp->sd_args.ar_localflocks)
720 return flock_lock_file_wait(file, fl);
721
722 if (fl->fl_type == F_UNLCK) { 710 if (fl->fl_type == F_UNLCK) {
723 do_unflock(file, fl); 711 do_unflock(file, fl);
724 return 0; 712 return 0;
@@ -755,3 +743,27 @@ const struct file_operations gfs2_dir_fops = {
755 .flock = gfs2_flock, 743 .flock = gfs2_flock,
756}; 744};
757 745
746const struct file_operations gfs2_file_fops_nolock = {
747 .llseek = gfs2_llseek,
748 .read = do_sync_read,
749 .aio_read = generic_file_aio_read,
750 .write = do_sync_write,
751 .aio_write = generic_file_aio_write,
752 .unlocked_ioctl = gfs2_ioctl,
753 .mmap = gfs2_mmap,
754 .open = gfs2_open,
755 .release = gfs2_close,
756 .fsync = gfs2_fsync,
757 .splice_read = generic_file_splice_read,
758 .splice_write = generic_file_splice_write,
759 .setlease = gfs2_setlease,
760};
761
762const struct file_operations gfs2_dir_fops_nolock = {
763 .readdir = gfs2_readdir,
764 .unlocked_ioctl = gfs2_ioctl,
765 .open = gfs2_open,
766 .release = gfs2_close,
767 .fsync = gfs2_fsync,
768};
769
diff --git a/fs/gfs2/ops_inode.h b/fs/gfs2/ops_inode.h
index edb519cb05ee..fd8cee231e1d 100644
--- a/fs/gfs2/ops_inode.h
+++ b/fs/gfs2/ops_inode.h
@@ -18,6 +18,8 @@ extern const struct inode_operations gfs2_symlink_iops;
18extern const struct inode_operations gfs2_dev_iops; 18extern const struct inode_operations gfs2_dev_iops;
19extern const struct file_operations gfs2_file_fops; 19extern const struct file_operations gfs2_file_fops;
20extern const struct file_operations gfs2_dir_fops; 20extern const struct file_operations gfs2_dir_fops;
21extern const struct file_operations gfs2_file_fops_nolock;
22extern const struct file_operations gfs2_dir_fops_nolock;
21 23
22extern void gfs2_set_inode_flags(struct inode *inode); 24extern void gfs2_set_inode_flags(struct inode *inode);
23 25