linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>,
	Oleg Drokin <oleg.drokin@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>,
	Aditya Pandit <panditadityashreesh@yahoo.com>,
	James Simmons <jsimmons@infradead.org>
Subject: [PATCH 15/35] staging: lustre: llite: tar restore fails for HSM released files.
Date: Thu, 10 Nov 2016 12:30:45 -0500	[thread overview]
Message-ID: <1478799065-24841-16-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1478799065-24841-1-git-send-email-jsimmons@infradead.org>

From: Aditya Pandit <panditadityashreesh@yahoo.com>

If you create a file, archive and release it, it keeps only a
link and all information in xattr. If you tar the file
with --xattr you will store the same striping information and link
information in the tar. If you delete the file, the file and archive
state does not make sense. Now if you restore the file using tar
with xattr having the RELEASED flag turned on, then it is not correct
because this is a new file. Hence ignoring the HSM xattr and masking
out the "RELEASED" flag for the files, which are not archived.

Signed-off-by: Aditya Pandit <panditadityashreesh@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6214
Reviewed-on: http://review.whamcloud.com/16060
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/lustre/include/lustre/lustre_user.h     |    1 +
 drivers/staging/lustre/lustre/llite/xattr.c        |   61 +++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index 579ef14..e393ae3 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -1001,6 +1001,7 @@ struct ioc_data_version {
  * See HSM_FLAGS below.
  */
 enum hsm_states {
+	HS_NONE		= 0x00000000,
 	HS_EXISTS	= 0x00000001,
 	HS_DIRTY	= 0x00000002,
 	HS_RELEASED	= 0x00000004,
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index ea3becc..7a848eb 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -112,8 +112,9 @@ static int xattr_type_filter(struct ll_sb_info *sbi,
 		return -EPERM;
 
 	/* b10667: ignore lustre special xattr for now */
-	if ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) ||
-	    (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov")))
+	if (!strcmp(name, "hsm") ||
+	    ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) ||
+	     (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))))
 		return 0;
 
 	/* b15587: ignore security.capability xattr for now */
@@ -147,6 +148,37 @@ static int xattr_type_filter(struct ll_sb_info *sbi,
 	return 0;
 }
 
+static int get_hsm_state(struct inode *inode, u32 *hus_states)
+{
+	struct md_op_data *op_data;
+	struct hsm_user_state *hus;
+	int rc;
+
+	hus = kzalloc(sizeof(*hus), GFP_NOFS);
+	if (!hus)
+		return -ENOMEM;
+
+	op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
+				     LUSTRE_OPC_ANY, hus);
+	if (!IS_ERR(op_data)) {
+		rc = obd_iocontrol(LL_IOC_HSM_STATE_GET, ll_i2mdexp(inode),
+				   sizeof(*op_data), op_data, NULL);
+		if (!rc)
+			*hus_states = hus->hus_states;
+		else
+			CDEBUG(D_VFSTRACE, "obd_iocontrol failed. rc = %d\n",
+			       rc);
+
+		ll_finish_md_op_data(op_data);
+	} else {
+		rc = PTR_ERR(op_data);
+		CDEBUG(D_VFSTRACE, "Could not prepare the opdata. rc = %d\n",
+		       rc);
+	}
+	kfree(hus);
+	return rc;
+}
+
 static int ll_xattr_set(const struct xattr_handler *handler,
 			struct dentry *dentry, struct inode *inode,
 			const char *name, const void *value, size_t size,
@@ -183,6 +215,31 @@ static int ll_xattr_set(const struct xattr_handler *handler,
 		if (lump && lump->lmm_stripe_offset == 0)
 			lump->lmm_stripe_offset = -1;
 
+		/* Avoid anyone directly setting the RELEASED flag. */
+		if (lump && (lump->lmm_pattern & LOV_PATTERN_F_RELEASED)) {
+			/* Only if we have a released flag check if the file
+			 * was indeed archived.
+			 */
+			u32 state = HS_NONE;
+
+			rc = get_hsm_state(inode, &state);
+			if (rc)
+				return rc;
+
+			if (!(state & HS_ARCHIVED)) {
+				CDEBUG(D_VFSTRACE,
+				       "hus_states state = %x, pattern = %x\n",
+				state, lump->lmm_pattern);
+				/*
+				 * Here the state is: real file is not
+				 * archived but user is requesting to set
+				 * the RELEASED flag so we mask off the
+				 * released flag from the request
+				 */
+				lump->lmm_pattern ^= LOV_PATTERN_F_RELEASED;
+			}
+		}
+
 		if (lump && S_ISREG(inode->i_mode)) {
 			__u64 it_flags = FMODE_WRITE;
 			int lum_size;
-- 
1.7.1

  parent reply	other threads:[~2016-11-10 17:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 17:30 [PATCH 00/35] second batch of missing lustre 2.8 patches James Simmons
2016-11-10 17:30 ` [PATCH 01/35] staging: lustre: hsm: Use file lease to implement migration James Simmons
2016-11-10 17:30 ` [PATCH 02/35] staging: lustre: obd: rename obd_unpackmd() to md_unpackmd() James Simmons
2016-11-10 17:30 ` [PATCH 03/35] staging: lustre: ptlrpc: mbits is sent within ptlrpc_body James Simmons
2016-11-10 17:30 ` [PATCH 04/35] staging: lustre: lov: init LOV stripe type beforehand James Simmons
2016-11-10 17:30 ` [PATCH 05/35] staging: lustre: llog: fix wrong offset in llog_process_thread() James Simmons
2016-11-11  4:35   ` kbuild test robot
2016-11-10 17:30 ` [PATCH 06/35] staging: lustre: osc: Performance tune for LRU James Simmons
2016-11-11  5:16   ` kbuild test robot
2016-11-10 17:30 ` [PATCH 07/35] staging: lustre: lov: avoid infinite loop in lsm_alloc_plain() James Simmons
2016-11-10 17:30 ` [PATCH 08/35] staging: lustre: lmv: lock necessary part of lmv_add_target James Simmons
2016-11-10 17:30 ` [PATCH 09/35] staging: lustre: mgc: IR log failure should not stop mount James Simmons
2016-11-10 17:30 ` [PATCH 10/35] staging: lustre: lmv: revalidate the dentry for striped dir James Simmons
2016-11-10 17:30 ` [PATCH 11/35] staging: lustre: ptlrpc: race at req processing James Simmons
2016-11-10 17:30 ` [PATCH 12/35] staging: lustre: clio: get rid of cl_req James Simmons
2016-11-10 17:30 ` [PATCH 13/35] staging: lustre: llite: lookup master inode by ilookup5_nowait James Simmons
2016-11-10 17:30 ` [PATCH 14/35] staging: lustre: nrs: serialize executions of nrs_policy_stop James Simmons
2016-11-10 17:30 ` James Simmons [this message]
2016-11-10 17:30 ` [PATCH 16/35] staging: lustre: llite: support SELinux context labelling James Simmons
2016-11-10 17:30 ` [PATCH 17/35] staging: lustre: obd: Remove dead code in precleanup James Simmons
2016-11-10 17:30 ` [PATCH 18/35] staging: lustre: osc: fix max_dirty_mb tunable setting limit James Simmons
2016-11-10 17:30 ` [PATCH 19/35] staging: lustre: obdclass: remove structure holes to reduce memory James Simmons
2016-11-10 17:30 ` [PATCH 20/35] staging: lustre: ptlrpc: Move IT_* definitions to lustre_idl.h James Simmons
2016-11-10 17:30 ` [PATCH 21/35] staging: lustre: statahead: lock leaks if statahead file recreated James Simmons
2016-11-10 17:30 ` [PATCH 22/35] staging: lustre: llite: clear dir stripe md in ll_iget James Simmons
2016-11-10 17:30 ` [PATCH 23/35] staging: lustre: ldlm: improve lock timeout messages James Simmons
2016-11-10 17:30 ` [PATCH 24/35] staging: lustre: osc: osc_extent should hold refcount to osc_object James Simmons
2016-11-10 17:30 ` [PATCH 25/35] staging: lustre: osc: Do not merge extents with partial pages James Simmons
2016-11-10 17:30 ` [PATCH 26/35] staging: lustre: mdc: remove console spew from mdc_ioc_fid2path James Simmons
2016-11-10 17:30 ` [PATCH 27/35] staging: lustre: ptlrpc: reset imp_replay_cursor James Simmons
2016-11-10 17:30 ` [PATCH 28/35] staging: lustre: osc: Remove remains of osc_ast_guard James Simmons
2016-11-10 17:30 ` [PATCH 29/35] staging: lustre: misc: clean up DFID related error messages James Simmons
2016-11-10 17:31 ` [PATCH 30/35] staging: lustre: llite: ll_write_begin/end not passing on errors James Simmons
2016-11-10 17:31 ` [PATCH 31/35] staging: lustre: obdclass: add export for lprocfs_stats_alloc_one() James Simmons
2016-11-14 14:59   ` Greg Kroah-Hartman
2016-11-10 17:31 ` [PATCH 32/35] staging: lustre: mount: fix lmd_parse() to handle commas in expr_list James Simmons
2016-11-14 15:12   ` Greg Kroah-Hartman
2016-11-18 16:54     ` James Simmons
2016-11-18 17:14       ` Greg Kroah-Hartman
2016-11-10 17:31 ` [PATCH 33/35] staging: lustre: hsm: prevent migration of HSM archived files James Simmons
2016-11-10 17:31 ` [PATCH 34/35] staging: lustre: lnet: add offset for selftest brw James Simmons
2016-11-10 17:31 ` [PATCH 35/35] staging: lustre: idl: clean up file attribute flags James Simmons
2016-11-14 15:16 ` [PATCH 00/35] second batch of missing lustre 2.8 patches Greg Kroah-Hartman
2016-11-14 18:27   ` James Simmons
2016-11-15 10:00     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478799065-24841-16-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    --cc=panditadityashreesh@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).