mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 23:23:03 +00:00
NFSv4: Add a flags argument to the 'have_delegation' callback
This argument will be used to allow the caller to specify whether or not they need to know that this is an attribute delegation. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
43df7110f4
commit
4201916f2a
@ -82,11 +82,10 @@ static void nfs_mark_return_delegation(struct nfs_server *server,
|
|||||||
set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state);
|
set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
|
||||||
nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
|
fmode_t type)
|
||||||
fmode_t flags)
|
|
||||||
{
|
{
|
||||||
if (delegation != NULL && (delegation->type & flags) == flags &&
|
if (delegation != NULL && (delegation->type & type) == type &&
|
||||||
!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) &&
|
!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) &&
|
||||||
!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
|
!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
|
||||||
return true;
|
return true;
|
||||||
@ -103,16 +102,16 @@ struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int nfs4_do_check_delegation(struct inode *inode, fmode_t type,
|
||||||
nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark)
|
int flags, bool mark)
|
||||||
{
|
{
|
||||||
struct nfs_delegation *delegation;
|
struct nfs_delegation *delegation;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
flags &= FMODE_READ|FMODE_WRITE;
|
type &= FMODE_READ|FMODE_WRITE;
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||||
if (nfs4_is_valid_delegation(delegation, flags)) {
|
if (nfs4_is_valid_delegation(delegation, type)) {
|
||||||
if (mark)
|
if (mark)
|
||||||
nfs_mark_delegation_referenced(delegation);
|
nfs_mark_delegation_referenced(delegation);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -124,22 +123,23 @@ nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark)
|
|||||||
* nfs4_have_delegation - check if inode has a delegation, mark it
|
* nfs4_have_delegation - check if inode has a delegation, mark it
|
||||||
* NFS_DELEGATION_REFERENCED if there is one.
|
* NFS_DELEGATION_REFERENCED if there is one.
|
||||||
* @inode: inode to check
|
* @inode: inode to check
|
||||||
* @flags: delegation types to check for
|
* @type: delegation types to check for
|
||||||
|
* @flags: various modifiers
|
||||||
*
|
*
|
||||||
* Returns one if inode has the indicated delegation, otherwise zero.
|
* Returns one if inode has the indicated delegation, otherwise zero.
|
||||||
*/
|
*/
|
||||||
int nfs4_have_delegation(struct inode *inode, fmode_t flags)
|
int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags)
|
||||||
{
|
{
|
||||||
return nfs4_do_check_delegation(inode, flags, true);
|
return nfs4_do_check_delegation(inode, type, flags, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nfs4_check_delegation - check if inode has a delegation, do not mark
|
* nfs4_check_delegation - check if inode has a delegation, do not mark
|
||||||
* NFS_DELEGATION_REFERENCED if it has one.
|
* NFS_DELEGATION_REFERENCED if it has one.
|
||||||
*/
|
*/
|
||||||
int nfs4_check_delegation(struct inode *inode, fmode_t flags)
|
int nfs4_check_delegation(struct inode *inode, fmode_t type)
|
||||||
{
|
{
|
||||||
return nfs4_do_check_delegation(inode, flags, false);
|
return nfs4_do_check_delegation(inode, type, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_stateid *stateid)
|
static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_stateid *stateid)
|
||||||
|
@ -75,8 +75,8 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
|
|||||||
|
|
||||||
struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode);
|
struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode);
|
||||||
void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
|
void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
|
||||||
int nfs4_have_delegation(struct inode *inode, fmode_t flags);
|
int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags);
|
||||||
int nfs4_check_delegation(struct inode *inode, fmode_t flags);
|
int nfs4_check_delegation(struct inode *inode, fmode_t type);
|
||||||
bool nfs4_delegation_flush_on_close(const struct inode *inode);
|
bool nfs4_delegation_flush_on_close(const struct inode *inode);
|
||||||
void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
|
void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
|
||||||
const nfs4_stateid *stateid);
|
const nfs4_stateid *stateid);
|
||||||
@ -84,9 +84,19 @@ int nfs4_inode_make_writeable(struct inode *inode);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline int nfs_have_read_or_write_delegation(struct inode *inode)
|
||||||
|
{
|
||||||
|
return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int nfs_have_write_delegation(struct inode *inode)
|
||||||
|
{
|
||||||
|
return NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int nfs_have_delegated_attributes(struct inode *inode)
|
static inline int nfs_have_delegated_attributes(struct inode *inode)
|
||||||
{
|
{
|
||||||
return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
|
return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1437,7 +1437,7 @@ static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf)
|
|||||||
|
|
||||||
if (!dir || !nfs_verify_change_attribute(dir, verf))
|
if (!dir || !nfs_verify_change_attribute(dir, verf))
|
||||||
return;
|
return;
|
||||||
if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0))
|
||||||
nfs_set_verifier_delegated(&verf);
|
nfs_set_verifier_delegated(&verf);
|
||||||
dentry->d_time = verf;
|
dentry->d_time = verf;
|
||||||
}
|
}
|
||||||
|
@ -732,7 +732,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
|||||||
}
|
}
|
||||||
fl->c.flc_type = saved_type;
|
fl->c.flc_type = saved_type;
|
||||||
|
|
||||||
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (nfs_have_read_or_write_delegation(inode))
|
||||||
goto out_noconflict;
|
goto out_noconflict;
|
||||||
|
|
||||||
if (is_local)
|
if (is_local)
|
||||||
@ -815,7 +815,7 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
|||||||
* This makes locking act as a cache coherency point.
|
* This makes locking act as a cache coherency point.
|
||||||
*/
|
*/
|
||||||
nfs_sync_mapping(filp->f_mapping);
|
nfs_sync_mapping(filp->f_mapping);
|
||||||
if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) {
|
if (!nfs_have_read_or_write_delegation(inode)) {
|
||||||
nfs_zap_caches(inode);
|
nfs_zap_caches(inode);
|
||||||
if (mapping_mapped(filp->f_mapping))
|
if (mapping_mapped(filp->f_mapping))
|
||||||
nfs_revalidate_mapping(inode, filp->f_mapping);
|
nfs_revalidate_mapping(inode, filp->f_mapping);
|
||||||
|
@ -190,9 +190,8 @@ static bool nfs_has_xattr_cache(const struct nfs_inode *nfsi)
|
|||||||
void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
|
void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
|
||||||
{
|
{
|
||||||
struct nfs_inode *nfsi = NFS_I(inode);
|
struct nfs_inode *nfsi = NFS_I(inode);
|
||||||
bool have_delegation = NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
|
|
||||||
|
|
||||||
if (have_delegation) {
|
if (nfs_have_delegated_attributes(inode)) {
|
||||||
if (!(flags & NFS_INO_REVAL_FORCED))
|
if (!(flags & NFS_INO_REVAL_FORCED))
|
||||||
flags &= ~(NFS_INO_INVALID_MODE |
|
flags &= ~(NFS_INO_INVALID_MODE |
|
||||||
NFS_INO_INVALID_OTHER |
|
NFS_INO_INVALID_OTHER |
|
||||||
@ -1013,7 +1012,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
|
|||||||
if (!is_sync)
|
if (!is_sync)
|
||||||
return;
|
return;
|
||||||
inode = d_inode(ctx->dentry);
|
inode = d_inode(ctx->dentry);
|
||||||
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (nfs_have_read_or_write_delegation(inode))
|
||||||
return;
|
return;
|
||||||
nfsi = NFS_I(inode);
|
nfsi = NFS_I(inode);
|
||||||
if (inode->i_mapping->nrpages == 0)
|
if (inode->i_mapping->nrpages == 0)
|
||||||
@ -1483,7 +1482,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
|
|||||||
unsigned long invalid = 0;
|
unsigned long invalid = 0;
|
||||||
struct timespec64 ts;
|
struct timespec64 ts;
|
||||||
|
|
||||||
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (nfs_have_delegated_attributes(inode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {
|
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {
|
||||||
|
@ -979,7 +979,7 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfs3_have_delegation(struct inode *inode, fmode_t flags)
|
static int nfs3_have_delegation(struct inode *inode, fmode_t type, int flags)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
|
|||||||
unsigned long cache_validity;
|
unsigned long cache_validity;
|
||||||
|
|
||||||
memcpy(dst, src, NFS4_BITMASK_SZ*sizeof(*dst));
|
memcpy(dst, src, NFS4_BITMASK_SZ*sizeof(*dst));
|
||||||
if (!inode || !nfs4_have_delegation(inode, FMODE_READ))
|
if (!inode || !nfs_have_read_or_write_delegation(inode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags;
|
cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags;
|
||||||
@ -1264,7 +1264,7 @@ nfs4_update_changeattr_locked(struct inode *inode,
|
|||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
nfs_force_lookup_revalidate(inode);
|
nfs_force_lookup_revalidate(inode);
|
||||||
|
|
||||||
if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (!nfs_have_delegated_attributes(inode))
|
||||||
cache_validity |=
|
cache_validity |=
|
||||||
NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
|
NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
|
||||||
NFS_INO_INVALID_SIZE | NFS_INO_INVALID_OTHER |
|
NFS_INO_INVALID_SIZE | NFS_INO_INVALID_OTHER |
|
||||||
@ -3700,7 +3700,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
|
|||||||
|
|
||||||
if (calldata->arg.fmode == 0 || calldata->arg.fmode == FMODE_READ) {
|
if (calldata->arg.fmode == 0 || calldata->arg.fmode == FMODE_READ) {
|
||||||
/* Close-to-open cache consistency revalidation */
|
/* Close-to-open cache consistency revalidation */
|
||||||
if (!nfs4_have_delegation(inode, FMODE_READ)) {
|
if (!nfs4_have_delegation(inode, FMODE_READ, 0)) {
|
||||||
nfs4_bitmask_set(calldata->arg.bitmask_store,
|
nfs4_bitmask_set(calldata->arg.bitmask_store,
|
||||||
server->cache_consistency_bitmask,
|
server->cache_consistency_bitmask,
|
||||||
inode, 0);
|
inode, 0);
|
||||||
@ -4638,7 +4638,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
|
|||||||
};
|
};
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (!nfs4_have_delegation(inode, FMODE_READ)) {
|
if (!nfs4_have_delegation(inode, FMODE_READ, 0)) {
|
||||||
res.fattr = nfs_alloc_fattr();
|
res.fattr = nfs_alloc_fattr();
|
||||||
if (res.fattr == NULL)
|
if (res.fattr == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -5607,7 +5607,7 @@ bool nfs4_write_need_cache_consistency_data(struct nfs_pgio_header *hdr)
|
|||||||
/* Otherwise, request attributes if and only if we don't hold
|
/* Otherwise, request attributes if and only if we don't hold
|
||||||
* a delegation
|
* a delegation
|
||||||
*/
|
*/
|
||||||
return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0;
|
return nfs4_have_delegation(hdr->inode, FMODE_READ, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[],
|
void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[],
|
||||||
@ -7654,10 +7654,10 @@ static int nfs4_add_lease(struct file *file, int arg, struct file_lease **lease,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* No delegation, no lease */
|
/* No delegation, no lease */
|
||||||
if (!nfs4_have_delegation(inode, type))
|
if (!nfs4_have_delegation(inode, type, 0))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
ret = generic_setlease(file, arg, lease, priv);
|
ret = generic_setlease(file, arg, lease, priv);
|
||||||
if (ret || nfs4_have_delegation(inode, type))
|
if (ret || nfs4_have_delegation(inode, type, 0))
|
||||||
return ret;
|
return ret;
|
||||||
/* We raced with a delegation return */
|
/* We raced with a delegation return */
|
||||||
nfs4_delete_lease(file, priv);
|
nfs4_delete_lease(file, priv);
|
||||||
|
@ -687,7 +687,7 @@ out_einval:
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfs_have_delegation(struct inode *inode, fmode_t flags)
|
static int nfs_have_delegation(struct inode *inode, fmode_t type, int flags)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1320,7 +1320,7 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio,
|
|||||||
return 0;
|
return 0;
|
||||||
if (!nfs_folio_write_uptodate(folio, pagelen))
|
if (!nfs_folio_write_uptodate(folio, pagelen))
|
||||||
return 0;
|
return 0;
|
||||||
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE))
|
if (nfs_have_write_delegation(inode))
|
||||||
return 1;
|
return 1;
|
||||||
if (!flctx || (list_empty_careful(&flctx->flc_flock) &&
|
if (!flctx || (list_empty_careful(&flctx->flc_flock) &&
|
||||||
list_empty_careful(&flctx->flc_posix)))
|
list_empty_careful(&flctx->flc_posix)))
|
||||||
|
@ -1830,7 +1830,7 @@ struct nfs_rpc_ops {
|
|||||||
int open_flags,
|
int open_flags,
|
||||||
struct iattr *iattr,
|
struct iattr *iattr,
|
||||||
int *);
|
int *);
|
||||||
int (*have_delegation)(struct inode *, fmode_t);
|
int (*have_delegation)(struct inode *, fmode_t, int);
|
||||||
struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
|
struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
|
||||||
struct nfs_client *(*init_client) (struct nfs_client *,
|
struct nfs_client *(*init_client) (struct nfs_client *,
|
||||||
const struct nfs_client_initdata *);
|
const struct nfs_client_initdata *);
|
||||||
|
Loading…
Reference in New Issue
Block a user