Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1b66fcc authored by Lai Siyao's avatar Lai Siyao Committed by Greg Kroah-Hartman
Browse files

staging: lustre: fid: do open-by-fid by default



Currently client open-by-fid often packs name into the request,
but the name may be invalid, eg. NFS export, and even if it's
valid, it may cause inconsistency because this operation is done
on this fid, which is globally unique, but name not.

Since open-by-fid doesn't pack name, for striped dir we can't know
parent stripe fid on client, so we set parent fid the same as
child fid, and MDT has to find its parent fid from linkea (this is
already supported by MDT).

M_CHECK_STALE becomes obsolete.

Unset MDS_OPEN_FL_INTERNAL from open syscall flags, because these
flags are internally used, and should not be set from user space.

It's not necessary to store parent fid in lli_pfid, because MDT
can get it's parent fid from linkea, and now that DNE stripe
directory stores master inode fid in lli_pfid, stop storing parent
fid to avoid conflict.

Signed-off-by: default avatarLai Siyao <lai.siyao@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3544
Reviewed-on: http://review.whamcloud.com/7476
Reviewed-on: http://review.whamcloud.com/10692


Reviewed-by: default avatarFan Yong <fan.yong@intel.com>
Reviewed-by: default avatarNathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: default avatarwangdi <di.wang@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent be191af9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2252,6 +2252,11 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa);
					      */
#define MDS_OPEN_RELEASE   02000000000000ULL /* Open the file for HSM release */

#define MDS_OPEN_FL_INTERNAL (MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS |	\
			      MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK |	\
			      MDS_OPEN_BY_FID | MDS_OPEN_LEASE |	\
			      MDS_OPEN_RELEASE)

enum mds_op_bias {
	MDS_CHECK_SPLIT		= 1 << 0,
	MDS_CROSS_REF		= 1 << 1,
+0 −1
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@

#include "obd_class.h"
#include "lustre_net.h"
#include "lustre_mds.h"
#include "lustre_ha.h"

/* 4UL * 1024 * 1024 */
+0 −3
Original line number Diff line number Diff line
@@ -58,9 +58,6 @@ struct mds_group_info {
#define MDD_OBD_NAME     "mdd_obd"
#define MDD_OBD_UUID     "mdd_obd_uuid"

/* these are local flags, used only on the client, private */
#define M_CHECK_STALE	   0200000000

/** @} mds */

#endif
+31 −40
Original line number Diff line number Diff line
@@ -379,53 +379,35 @@ int ll_file_release(struct inode *inode, struct file *file)
	return rc;
}

static int ll_intent_file_open(struct dentry *dentry, void *lmm,
			       int lmmsize, struct lookup_intent *itp)
static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize,
			       struct lookup_intent *itp)
{
	struct inode *inode = d_inode(dentry);
	struct inode *inode = d_inode(de);
	struct ll_sb_info *sbi = ll_i2sbi(inode);
	struct dentry *parent = dentry->d_parent;
	const char *name = dentry->d_name.name;
	const int len = dentry->d_name.len;
	struct dentry *parent = de->d_parent;
	const char *name = NULL;
	struct md_op_data *op_data;
	struct ptlrpc_request *req;
	__u32 opc = LUSTRE_OPC_ANY;
	int rc;
	int len = 0, rc;

	LASSERT(parent);
	LASSERT(itp->it_flags & MDS_OPEN_BY_FID);

	/* Usually we come here only for NFSD, and we want open lock. */
	/* We can also get here if there was cached open handle in revalidate_it
	 * but it disappeared while we were getting from there to ll_file_open.
	 * But this means this file was closed and immediately opened which
	 * makes a good candidate for using OPEN lock
	 */
	/* If lmmsize & lmm are not 0, we are just setting stripe info
	 * parameters. No need for the open lock
	 */
	if (!lmm && lmmsize == 0) {
		struct ll_dentry_data *ldd = ll_d2d(dentry);
	/*
		 * If we came via ll_iget_for_nfs, then we need to request
		 * struct ll_dentry_data *ldd = ll_d2d(file->f_dentry);
		 *
		 * NB: when ldd is NULL, it must have come via normal
		 * lookup path only, since ll_iget_for_nfs always calls
		 * ll_d_init().
	 * if server supports open-by-fid, or file name is invalid, don't pack
	 * name in open request
	 */
		if (ldd && ldd->lld_nfs_dentry) {
			ldd->lld_nfs_dentry = 0;
			itp->it_flags |= MDS_OPEN_LOCK;
		}
		if (itp->it_flags & FMODE_WRITE)
			opc = LUSTRE_OPC_CREATE;
	if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_OPEN_BY_FID) &&
	    lu_name_is_valid_2(de->d_name.name, de->d_name.len)) {
		name = de->d_name.name;
		len = de->d_name.len;
	}

	op_data  = ll_prep_md_op_data(NULL, d_inode(parent),
				      inode, name, len,
				      O_RDWR, opc, NULL);
	op_data  = ll_prep_md_op_data(NULL, d_inode(parent), inode, name, len,
				      O_RDWR, LUSTRE_OPC_ANY, NULL);
	if (IS_ERR(op_data))
		return PTR_ERR(op_data);

	itp->it_flags |= MDS_OPEN_BY_FID;
	rc = md_intent_lock(sbi->ll_md_exp, op_data, lmm, lmmsize, itp,
			    0 /*unused */, &req, ll_md_blocking_ast, 0);
	ll_finish_md_op_data(op_data);
@@ -655,9 +637,19 @@ int ll_file_open(struct inode *inode, struct file *file)
			 * result in a deadlock
			 */
			mutex_unlock(&lli->lli_och_mutex);
			it->it_create_mode |= M_CHECK_STALE;
			/*
			 * Normally called under two situations:
			 * 1. NFS export.
			 * 2. revalidate with IT_OPEN (revalidate doesn't
			 *    execute this intent any more).
			 *
			 * Always fetch MDS_OPEN_LOCK if this is not setstripe.
			 *
			 * Always specify MDS_OPEN_BY_FID because we don't want
			 * to get file with different fid.
			 */
			it->it_flags |= MDS_OPEN_LOCK | MDS_OPEN_BY_FID;
			rc = ll_intent_file_open(file->f_path.dentry, NULL, 0, it);
			it->it_create_mode &= ~M_CHECK_STALE;
			if (rc)
				goto out_openerr;

@@ -1399,6 +1391,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
	}

	ll_inode_size_lock(inode);
	oit.it_flags |= MDS_OPEN_BY_FID;
	rc = ll_intent_file_open(dentry, lum, lum_size, &oit);
	if (rc)
		goto out_unlock;
@@ -3066,7 +3059,6 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
		if (IS_ERR(op_data))
			return PTR_ERR(op_data);

		oit.it_create_mode |= M_CHECK_STALE;
		rc = md_intent_lock(exp, op_data, NULL, 0,
				    /* we are not interested in name
				     * based lookup
@@ -3074,7 +3066,6 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
				    &oit, 0, &req,
				    ll_md_blocking_ast, 0);
		ll_finish_md_op_data(op_data);
		oit.it_create_mode &= ~M_CHECK_STALE;
		if (rc < 0) {
			rc = ll_inode_revalidate_fini(inode, rc);
			goto out;
+1 −3
Original line number Diff line number Diff line
@@ -118,9 +118,7 @@ struct ll_inode_info {

	/* identifying fields for both metadata and data stacks. */
	struct lu_fid		   lli_fid;
	/* Parent fid for accessing default stripe data on parent directory
	 * for allocating OST objects after a mknod() and later open-by-FID.
	 */
	/* master inode fid for stripe directory */
	struct lu_fid		   lli_pfid;

	struct list_head	      lli_close_list;
Loading