Commit a71029b8 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Fix nfs4_bitmap_copy_adjust()



Don't remove flags from the set retrieved from the cache_validity.
We do want to retrieve all attributes that are listed as being
invalid, whether or not there is a delegation set.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 36a9346c
Loading
Loading
Loading
Loading
+16 −17
Original line number Original line Diff line number Diff line
@@ -284,7 +284,7 @@ const u32 nfs4_fs_locations_bitmap[3] = {
};
};


static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
		struct inode *inode)
				    struct inode *inode, unsigned long flags)
{
{
	unsigned long cache_validity;
	unsigned long cache_validity;


@@ -292,22 +292,19 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
	if (!inode || !nfs4_have_delegation(inode, FMODE_READ))
	if (!inode || !nfs4_have_delegation(inode, FMODE_READ))
		return;
		return;


	cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
	cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags;
	if (!(cache_validity & NFS_INO_REVAL_FORCED))
		cache_validity &= ~(NFS_INO_INVALID_CHANGE
				| NFS_INO_INVALID_SIZE);


	/* Remove the attributes over which we have full control */
	dst[1] &= ~FATTR4_WORD1_RAWDEV;
	if (!(cache_validity & NFS_INO_INVALID_SIZE))
	if (!(cache_validity & NFS_INO_INVALID_SIZE))
		dst[0] &= ~FATTR4_WORD0_SIZE;
		dst[0] &= ~FATTR4_WORD0_SIZE;


	if (!(cache_validity & NFS_INO_INVALID_CHANGE))
	if (!(cache_validity & NFS_INO_INVALID_CHANGE))
		dst[0] &= ~FATTR4_WORD0_CHANGE;
		dst[0] &= ~FATTR4_WORD0_CHANGE;
}


static void nfs4_bitmap_copy_adjust_setattr(__u32 *dst,
	if (!(cache_validity & NFS_INO_INVALID_OTHER))
		const __u32 *src, struct inode *inode)
		dst[1] &= ~(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER |
{
			    FATTR4_WORD1_OWNER_GROUP);
	nfs4_bitmap_copy_adjust(dst, src, inode);
}
}


static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
@@ -3344,12 +3341,15 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
		.inode = inode,
		.inode = inode,
		.stateid = &arg.stateid,
		.stateid = &arg.stateid,
	};
	};
	unsigned long adjust_flags = NFS_INO_INVALID_CHANGE;
	int err;
	int err;


	if (sattr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID))
		adjust_flags |= NFS_INO_INVALID_OTHER;

	do {
	do {
		nfs4_bitmap_copy_adjust_setattr(bitmask,
		nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, olabel),
				nfs4_bitmask(server, olabel),
					inode, adjust_flags);
				inode);


		err = _nfs4_do_setattr(inode, &arg, &res, cred, ctx);
		err = _nfs4_do_setattr(inode, &arg, &res, cred, ctx);
		switch (err) {
		switch (err) {
@@ -4157,8 +4157,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
	if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
	if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
		task_flags |= RPC_TASK_TIMEOUT;
		task_flags |= RPC_TASK_TIMEOUT;


	nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode);
	nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode, 0);

	nfs_fattr_init(fattr);
	nfs_fattr_init(fattr);
	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
	return nfs4_do_call_sync(server->client, server, &msg,
	return nfs4_do_call_sync(server->client, server, &msg,
@@ -4764,8 +4763,8 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct
	}
	}


	nfs4_inode_make_writeable(inode);
	nfs4_inode_make_writeable(inode);
	nfs4_bitmap_copy_adjust_setattr(bitmask, nfs4_bitmask(server, res.label), inode);
	nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, res.label), inode,

				NFS_INO_INVALID_CHANGE);
	status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
	status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
	if (!status) {
	if (!status) {
		nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start,
		nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start,