From b0ed286e9b53c5ad24f04686cd6ddfad940b87f3 Mon Sep 17 00:00:00 2001 From: vmallika Date: Mon, 29 Sep 2014 13:02:30 +0530 Subject: glusterd/quota: Heal pgfid xattr on existing data when the quota is enable Backport of: http://review.gluster.org/8878 The pgfid extended attributes are used to construct the ancestry path (from the file to the volume root) for nameless lookups on files. As NFS relies on nameless lookups heavily, quota enforcement through NFS would be inconsistent if quota were to be enabled on a volume with existing data. Solution is to heal the pgfid extended attributes as a part of lookup perfomed by quota-crawl process. In a posix lookup check for pgfid xattr and if it is missing set the xattr. Change-Id: I956128907aa1d975cd5719ed3ab2f4f9b37d4c31 BUG: 1153900 Signed-off-by: vmallika Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/8938 Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- xlators/storage/posix/src/posix.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'xlators/storage/posix/src/posix.c') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 3ab2df70a3e..bbb27e3a376 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -105,6 +105,8 @@ posix_lookup (call_frame_t *frame, xlator_t *this, char * par_path = NULL; struct iatt postparent = {0,}; int32_t gfidless = 0; + char *pgfid_xattr_key = NULL; + int32_t nlink_samepgfid = 0; struct posix_private *priv = NULL; VALIDATE_OR_GOTO (frame, out); @@ -160,6 +162,25 @@ posix_lookup (call_frame_t *frame, xlator_t *this, xdata, &buf); } + if (priv->update_pgfid_nlinks) { + if (!uuid_is_null (loc->pargfid) && !IA_ISDIR (buf.ia_type)) { + MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, + PGFID_XATTR_KEY_PREFIX, + loc->pargfid); + + LOCK (&loc->inode->lock); + { + SET_PGFID_XATTR_IF_ABSENT (real_path, + pgfid_xattr_key, + nlink_samepgfid, + XATTR_CREATE, op_ret, + this, unlock); + } +unlock: + UNLOCK (&loc->inode->lock); + } + } + parent: if (par_path) { op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); -- cgit