diff options
author | Trond Myklebust <trond.myklebust@fys.uio.no> | 2005-01-04 21:42:56 +0100 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@fys.uio.no> | 2005-01-04 21:42:56 +0100 |
commit | 07e9eb2bc26214b844997867bfa9732b5dd3c878 (patch) | |
tree | 4250ce9e722960fdc83ad259cea3dec76e742265 /fs | |
parent | eaffe965448685d2f8db3a29cf00c132f296abb6 (diff) | |
download | history-07e9eb2bc26214b844997867bfa9732b5dd3c878.tar.gz |
NFS: when we mount with the "nolock" flag we need to use local locking.
Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/file.c | 50 | ||||
-rw-r--r-- | fs/nfs/inode.c | 23 |
2 files changed, 44 insertions, 29 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 21071ddd466277..7f1132b472be79 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -295,10 +295,19 @@ out_swapfile: static int do_getlk(struct file *filp, int cmd, struct file_lock *fl) { struct inode *inode = filp->f_mapping->host; - int status; + int status = 0; lock_kernel(); - status = NFS_PROTO(inode)->lock(filp, cmd, fl); + /* Use local locking if mounted with "-onolock" */ + if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)) + status = NFS_PROTO(inode)->lock(filp, cmd, fl); + else { + struct file_lock *cfl = posix_test_lock(filp, fl); + if (cfl != NULL) { + memcpy(fl, cfl, sizeof(*fl)); + fl->fl_type = F_UNLCK; + } + } unlock_kernel(); return status; } @@ -325,7 +334,11 @@ static int do_unlk(struct file *filp, int cmd, struct file_lock *fl) * still need to complete the unlock. */ lock_kernel(); - status = NFS_PROTO(inode)->lock(filp, cmd, fl); + /* Use local locking if mounted with "-onolock" */ + if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)) + status = NFS_PROTO(inode)->lock(filp, cmd, fl); + else + status = posix_lock_file_wait(filp, fl); rpc_clnt_sigunmask(NFS_CLIENT(inode), &oldset); return status; } @@ -351,15 +364,19 @@ static int do_setlk(struct file *filp, int cmd, struct file_lock *fl) return status; lock_kernel(); - status = NFS_PROTO(inode)->lock(filp, cmd, fl); - /* If we were signalled we still need to ensure that - * we clean up any state on the server. We therefore - * record the lock call as having succeeded in order to - * ensure that locks_remove_posix() cleans it out when - * the process exits. - */ - if (status == -EINTR || status == -ERESTARTSYS) - posix_lock_file(filp, fl); + /* Use local locking if mounted with "-onolock" */ + if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)) { + status = NFS_PROTO(inode)->lock(filp, cmd, fl); + /* If we were signalled we still need to ensure that + * we clean up any state on the server. We therefore + * record the lock call as having succeeded in order to + * ensure that locks_remove_posix() cleans it out when + * the process exits. + */ + if (status == -EINTR || status == -ERESTARTSYS) + posix_lock_file(filp, fl); + } else + status = posix_lock_file_wait(filp, fl); unlock_kernel(); if (status < 0) return status; @@ -396,15 +413,6 @@ nfs_lock(struct file *filp, int cmd, struct file_lock *fl) if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) return -ENOLCK; - if (NFS_PROTO(inode)->version != 4) { - /* Fake OK code if mounted without NLM support */ - if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM) { - if (IS_GETLK(cmd)) - return LOCK_USE_CLNT; - return 0; - } - } - /* * No BSD flocks over NFS allowed. * Note: we could try to fake a POSIX lock request here by diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index c2706fd0854d70..5342ba3344d3b5 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1449,8 +1449,6 @@ static void nfs_kill_super(struct super_block *s) kill_anon_super(s); - nfs4_renewd_prepare_shutdown(server); - if (server->client != NULL && !IS_ERR(server->client)) rpc_shutdown_client(server->client); if (server->client_sys != NULL && !IS_ERR(server->client_sys)) @@ -1461,8 +1459,6 @@ static void nfs_kill_super(struct super_block *s) rpciod_down(); /* release rpciod */ - destroy_nfsv4_state(server); - if (server->hostname != NULL) kfree(server->hostname); kfree(server); @@ -1543,9 +1539,6 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, server->wsize = nfs_block_size(data->wsize, NULL); server->flags = data->flags & NFS_MOUNT_FLAGMASK; - /* NFSv4 doesn't use NLM locking */ - server->flags |= NFS_MOUNT_NONLM; - server->acregmin = data->acregmin*HZ; server->acregmax = data->acregmax*HZ; server->acdirmin = data->acdirmin*HZ; @@ -1790,8 +1783,22 @@ out_free: static void nfs4_kill_super(struct super_block *sb) { + struct nfs_server *server = NFS_SB(sb); + nfs_return_all_delegations(sb); - nfs_kill_super(sb); + kill_anon_super(sb); + + nfs4_renewd_prepare_shutdown(server); + + if (server->client != NULL && !IS_ERR(server->client)) + rpc_shutdown_client(server->client); + rpciod_down(); /* release rpciod */ + + destroy_nfsv4_state(server); + + if (server->hostname != NULL) + kfree(server->hostname); + kfree(server); } static struct file_system_type nfs4_fs_type = { |