diff options
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix-handle.h | 16 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 21 |
2 files changed, 37 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h index a30e0296140..a34b936229b 100644 --- a/xlators/storage/posix/src/posix-handle.h +++ b/xlators/storage/posix/src/posix-handle.h @@ -51,6 +51,22 @@ } \ } while (0) +#define SET_PGFID_XATTR_IF_ABSENT(path, key, value, flags, op_ret, this, label)\ + do { \ + op_ret = sys_lgetxattr (path, key, &value, sizeof (value)); \ + if (op_ret == -1) { \ + op_errno = errno; \ + if (op_errno == ENOATTR) { \ + value = 1; \ + SET_PGFID_XATTR (path, key, value, flags, \ + op_ret, this, label); \ + } else { \ + gf_log(this->name, GF_LOG_WARNING, "getting " \ + "xattr failed on %s: key = %s (%s)", \ + path, key, strerror (op_errno)); \ + } \ + } \ + } while (0) #define REMOVE_PGFID_XATTR(path, key, op_ret, this, label) do { \ op_ret = sys_lremovexattr (path, key); \ diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e830a973b76..4abea837765 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -104,6 +104,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); @@ -157,6 +159,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); |