aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/inode.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2008-07-21 17:29:16 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 16:57:57 -0400
commit53da4939f349d4edd283b043219221ca5b78e4d4 (patch)
tree3e0f8e1bd5474822431cffd1e449df9b639e1772 /fs/ocfs2/inode.c
parenta447c0932445f92ce6f4c1bd020f62c5097a7842 (diff)
ocfs2: POSIX file locks support
This is actually pretty easy since fs/dlm already handles the bulk of the work. The Ocfs2 userspace cluster stack module already uses fs/dlm as the underlying lock manager, so I only had to add the right calls. Cluster-aware POSIX locks ("plocks") can be turned off by the same means at UNIX locks - mount with 'noflocks', or create a local-only Ocfs2 volume. Internally, the file system uses two sets of file_operations, depending on whether cluster aware plocks is required. This turns out to be easier than implementing local-only versions of ->lock. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/inode.c')
-rw-r--r--fs/ocfs2/inode.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 7e9e4c79aec7..99f012a0f207 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -219,6 +219,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
219 struct super_block *sb; 219 struct super_block *sb;
220 struct ocfs2_super *osb; 220 struct ocfs2_super *osb;
221 int status = -EINVAL; 221 int status = -EINVAL;
222 int use_plocks = 1;
222 223
223 mlog_entry("(0x%p, size:%llu)\n", inode, 224 mlog_entry("(0x%p, size:%llu)\n", inode,
224 (unsigned long long)le64_to_cpu(fe->i_size)); 225 (unsigned long long)le64_to_cpu(fe->i_size));
@@ -226,6 +227,10 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
226 sb = inode->i_sb; 227 sb = inode->i_sb;
227 osb = OCFS2_SB(sb); 228 osb = OCFS2_SB(sb);
228 229
230 if ((osb->s_mount_opt & OCFS2_MOUNT_LOCALFLOCKS) ||
231 ocfs2_mount_local(osb) || !ocfs2_stack_supports_plocks())
232 use_plocks = 0;
233
229 /* this means that read_inode cannot create a superblock inode 234 /* this means that read_inode cannot create a superblock inode
230 * today. change if needed. */ 235 * today. change if needed. */
231 if (!OCFS2_IS_VALID_DINODE(fe) || 236 if (!OCFS2_IS_VALID_DINODE(fe) ||
@@ -295,13 +300,19 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
295 300
296 switch (inode->i_mode & S_IFMT) { 301 switch (inode->i_mode & S_IFMT) {
297 case S_IFREG: 302 case S_IFREG:
298 inode->i_fop = &ocfs2_fops; 303 if (use_plocks)
304 inode->i_fop = &ocfs2_fops;
305 else
306 inode->i_fop = &ocfs2_fops_no_plocks;
299 inode->i_op = &ocfs2_file_iops; 307 inode->i_op = &ocfs2_file_iops;
300 i_size_write(inode, le64_to_cpu(fe->i_size)); 308 i_size_write(inode, le64_to_cpu(fe->i_size));
301 break; 309 break;
302 case S_IFDIR: 310 case S_IFDIR:
303 inode->i_op = &ocfs2_dir_iops; 311 inode->i_op = &ocfs2_dir_iops;
304 inode->i_fop = &ocfs2_dops; 312 if (use_plocks)
313 inode->i_fop = &ocfs2_dops;
314 else
315 inode->i_fop = &ocfs2_dops_no_plocks;
305 i_size_write(inode, le64_to_cpu(fe->i_size)); 316 i_size_write(inode, le64_to_cpu(fe->i_size));
306 break; 317 break;
307 case S_IFLNK: 318 case S_IFLNK: