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

Commit 5ea17d6c authored by JC Lafoucriere's avatar JC Lafoucriere Committed by Greg Kroah-Hartman
Browse files

staging/lustre/llite: Access to released file triggers a restore

When a client accesses data in a released file,
or truncate it, client must trig a restore request.
During this restore, the client must not glimpse and
must use size from MDT. To bring the "restore is running"
information on the client we add a new t_state bit field
to mdt_info which will be used to carry transient file state.
To memorise this information in the inode we add a new flag
LLIF_FILE_RESTORING.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3432
Lustre-change: http://review.whamcloud.com/6537


Signed-off-by: default avatarJC Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Tested-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e1970ee7
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -2388,7 +2388,11 @@ struct cl_io {
	 * Right now, only two opertaions need to verify layout: glimpse
	 * Right now, only two opertaions need to verify layout: glimpse
	 * and setattr.
	 * and setattr.
	 */
	 */
			     ci_verify_layout:1;
			     ci_verify_layout:1,
	/**
	 * file is released, restore has to to be triggered by vvp layer
	 */
			     ci_restore_needed:1;
	/**
	/**
	 * Number of pages owned by this IO. For invariant checking.
	 * Number of pages owned by this IO. For invariant checking.
	 */
	 */
+9 −5
Original line number Original line Diff line number Diff line
@@ -1725,10 +1725,7 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
#define OBD_MD_MDS	 (0x0000000100000000ULL) /* where an inode lives on */
#define OBD_MD_MDS	 (0x0000000100000000ULL) /* where an inode lives on */
#define OBD_MD_REINT       (0x0000000200000000ULL) /* reintegrate oa */
#define OBD_MD_REINT       (0x0000000200000000ULL) /* reintegrate oa */
#define OBD_MD_MEA	 (0x0000000400000000ULL) /* CMD split EA  */
#define OBD_MD_MEA	 (0x0000000400000000ULL) /* CMD split EA  */

#define OBD_MD_TSTATE      (0x0000000800000000ULL) /* transient state field */
/* OBD_MD_MDTIDX is used to get MDT index, but it is never been used overwire,
 * and it is already obsolete since 2.3 */
/* #define OBD_MD_MDTIDX      (0x0000000800000000ULL) */


#define OBD_MD_FLXATTR       (0x0000001000000000ULL) /* xattr */
#define OBD_MD_FLXATTR       (0x0000001000000000ULL) /* xattr */
#define OBD_MD_FLXATTRLS     (0x0000002000000000ULL) /* xattr list */
#define OBD_MD_FLXATTRLS     (0x0000002000000000ULL) /* xattr list */
@@ -2208,6 +2205,11 @@ static inline int ll_inode_to_ext_flags(int iflags)
		((iflags & S_IMMUTABLE) ? LUSTRE_IMMUTABLE_FL : 0));
		((iflags & S_IMMUTABLE) ? LUSTRE_IMMUTABLE_FL : 0));
}
}


/* 64 possible states */
enum md_transient_state {
	MS_RESTORE	= (1 << 0),	/* restore is running */
};

struct mdt_body {
struct mdt_body {
	struct lu_fid  fid1;
	struct lu_fid  fid1;
	struct lu_fid  fid2;
	struct lu_fid  fid2;
@@ -2219,7 +2221,9 @@ struct mdt_body {
       obd_time	ctime;
       obd_time	ctime;
	__u64	  blocks; /* XID, in the case of MDS_READPAGE */
	__u64	  blocks; /* XID, in the case of MDS_READPAGE */
	__u64	  ioepoch;
	__u64	  ioepoch;
	__u64	       unused1; /* was "ino" until 2.4.0 */
	__u64	       t_state; /* transient file state defined in
				 * enum md_transient_state
				 * was "ino" until 2.4.0 */
	__u32	  fsuid;
	__u32	  fsuid;
	__u32	  fsgid;
	__u32	  fsgid;
	__u32	  capability;
	__u32	  capability;
+6 −0
Original line number Original line Diff line number Diff line
@@ -1006,6 +1006,12 @@ again:
	cl_io_fini(env, io);
	cl_io_fini(env, io);
	if (unlikely(io->ci_need_restart))
	if (unlikely(io->ci_need_restart))
		goto again;
		goto again;
	/* HSM import case: file is released, cannot be restored
	 * no need to fail except if restore registration failed
	 * with -ENODATA */
	if (result == -ENODATA && io->ci_restore_needed &&
	    io->ci_result != -ENODATA)
		result = 0;
	cl_env_put(env, &refcheck);
	cl_env_put(env, &refcheck);
	return result;
	return result;
}
}
+37 −2
Original line number Original line Diff line number Diff line
@@ -1107,7 +1107,7 @@ out:
	cl_io_fini(env, io);
	cl_io_fini(env, io);
	/* If any bit been read/written (result != 0), we just return
	/* If any bit been read/written (result != 0), we just return
	 * short read/write instead of restart io. */
	 * short read/write instead of restart io. */
	if (result == 0 && io->ci_need_restart) {
	if ((result == 0 || result == -ENODATA) && io->ci_need_restart) {
		CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zd\n",
		CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zd\n",
		       iot == CIT_READ ? "read" : "write",
		       iot == CIT_READ ? "read" : "write",
		       file->f_dentry->d_name.name, *ppos, count);
		       file->f_dentry->d_name.name, *ppos, count);
@@ -2867,6 +2867,14 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
		LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_lvb.lvb_mtime;
		LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_lvb.lvb_mtime;
		LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_lvb.lvb_ctime;
		LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_lvb.lvb_ctime;
	} else {
	} else {
		/* In case of restore, the MDT has the right size and has
		 * already send it back without granting the layout lock,
		 * inode is up-to-date so glimpse is useless.
		 * Also to glimpse we need the layout, in case of a running
		 * restore the MDT holds the layout lock so the glimpse will
		 * block up to the end of restore (getattr will block)
		 */
		if (!(ll_i2info(inode)->lli_flags & LLIF_FILE_RESTORING))
			rc = ll_glimpse_size(inode);
			rc = ll_glimpse_size(inode);
	}
	}
	return rc;
	return rc;
@@ -3464,3 +3472,30 @@ again:


	return rc;
	return rc;
}
}

/**
 *  This function send a restore request to the MDT
 */
int ll_layout_restore(struct inode *inode)
{
	struct hsm_user_request	*hur;
	int			 len, rc;

	len = sizeof(struct hsm_user_request) +
	      sizeof(struct hsm_user_item);
	OBD_ALLOC(hur, len);
	if (hur == NULL)
		return -ENOMEM;

	hur->hur_request.hr_action = HUA_RESTORE;
	hur->hur_request.hr_archive_id = 0;
	hur->hur_request.hr_flags = 0;
	memcpy(&hur->hur_user_item[0].hui_fid, &ll_i2info(inode)->lli_fid,
	       sizeof(hur->hur_user_item[0].hui_fid));
	hur->hur_user_item[0].hui_extent.length = -1;
	hur->hur_request.hr_itemcount = 1;
	rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp,
			   len, hur, NULL);
	OBD_FREE(hur, len);
	return rc;
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -125,6 +125,8 @@ enum lli_flags {
	LLIF_SRVLOCK	    = (1 << 5),
	LLIF_SRVLOCK	    = (1 << 5),
	/* File data is modified. */
	/* File data is modified. */
	LLIF_DATA_MODIFIED      = (1 << 6),
	LLIF_DATA_MODIFIED      = (1 << 6),
	/* File is being restored */
	LLIF_FILE_RESTORING	= (1 << 7),
};
};


struct ll_inode_info {
struct ll_inode_info {
@@ -1588,5 +1590,6 @@ enum {


int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
int ll_layout_refresh(struct inode *inode, __u32 *gen);
int ll_layout_refresh(struct inode *inode, __u32 *gen);
int ll_layout_restore(struct inode *inode);


#endif /* LLITE_INTERNAL_H */
#endif /* LLITE_INTERNAL_H */
Loading