aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/file.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/file.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/file.c')
-rw-r--r--fs/ocfs2/file.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ed38796052d2..1015ef16a8bf 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2237,6 +2237,10 @@ const struct inode_operations ocfs2_special_file_iops = {
2237 .permission = ocfs2_permission, 2237 .permission = ocfs2_permission,
2238}; 2238};
2239 2239
2240/*
2241 * Other than ->lock, keep ocfs2_fops and ocfs2_dops in sync with
2242 * ocfs2_fops_no_plocks and ocfs2_dops_no_plocks!
2243 */
2240const struct file_operations ocfs2_fops = { 2244const struct file_operations ocfs2_fops = {
2241 .llseek = generic_file_llseek, 2245 .llseek = generic_file_llseek,
2242 .read = do_sync_read, 2246 .read = do_sync_read,
@@ -2251,6 +2255,7 @@ const struct file_operations ocfs2_fops = {
2251#ifdef CONFIG_COMPAT 2255#ifdef CONFIG_COMPAT
2252 .compat_ioctl = ocfs2_compat_ioctl, 2256 .compat_ioctl = ocfs2_compat_ioctl,
2253#endif 2257#endif
2258 .lock = ocfs2_lock,
2254 .flock = ocfs2_flock, 2259 .flock = ocfs2_flock,
2255 .splice_read = ocfs2_file_splice_read, 2260 .splice_read = ocfs2_file_splice_read,
2256 .splice_write = ocfs2_file_splice_write, 2261 .splice_write = ocfs2_file_splice_write,
@@ -2267,5 +2272,51 @@ const struct file_operations ocfs2_dops = {
2267#ifdef CONFIG_COMPAT 2272#ifdef CONFIG_COMPAT
2268 .compat_ioctl = ocfs2_compat_ioctl, 2273 .compat_ioctl = ocfs2_compat_ioctl,
2269#endif 2274#endif
2275 .lock = ocfs2_lock,
2276 .flock = ocfs2_flock,
2277};
2278
2279/*
2280 * POSIX-lockless variants of our file_operations.
2281 *
2282 * These will be used if the underlying cluster stack does not support
2283 * posix file locking, if the user passes the "localflocks" mount
2284 * option, or if we have a local-only fs.
2285 *
2286 * ocfs2_flock is in here because all stacks handle UNIX file locks,
2287 * so we still want it in the case of no stack support for
2288 * plocks. Internally, it will do the right thing when asked to ignore
2289 * the cluster.
2290 */
2291const struct file_operations ocfs2_fops_no_plocks = {
2292 .llseek = generic_file_llseek,
2293 .read = do_sync_read,
2294 .write = do_sync_write,
2295 .mmap = ocfs2_mmap,
2296 .fsync = ocfs2_sync_file,
2297 .release = ocfs2_file_release,
2298 .open = ocfs2_file_open,
2299 .aio_read = ocfs2_file_aio_read,
2300 .aio_write = ocfs2_file_aio_write,
2301 .unlocked_ioctl = ocfs2_ioctl,
2302#ifdef CONFIG_COMPAT
2303 .compat_ioctl = ocfs2_compat_ioctl,
2304#endif
2305 .flock = ocfs2_flock,
2306 .splice_read = ocfs2_file_splice_read,
2307 .splice_write = ocfs2_file_splice_write,
2308};
2309
2310const struct file_operations ocfs2_dops_no_plocks = {
2311 .llseek = generic_file_llseek,
2312 .read = generic_read_dir,
2313 .readdir = ocfs2_readdir,
2314 .fsync = ocfs2_sync_file,
2315 .release = ocfs2_dir_release,
2316 .open = ocfs2_dir_open,
2317 .unlocked_ioctl = ocfs2_ioctl,
2318#ifdef CONFIG_COMPAT
2319 .compat_ioctl = ocfs2_compat_ioctl,
2320#endif
2270 .flock = ocfs2_flock, 2321 .flock = ocfs2_flock,
2271}; 2322};