diff options
author | Kotresh HR <khiremat@redhat.com> | 2018-04-02 08:31:25 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-05-06 07:09:08 +0530 |
commit | f8fe0771f0b450713595a7d298ed5a758cf2ce3e (patch) | |
tree | 8066610f5d3343c5f71b52c9159a701e7450c7a3 /xlators/storage/posix/src/posix-entry-ops.c | |
parent | 9a854a98af69c1b7e06aa01dff7ea3271ebd574c (diff) |
posix/ctime: posix hook to set ctime xattr in relevant fops
This patch uses the ctime posix APIs to set consistent
time across replica on disk. It also stores the time
attributes in the inode context.
Credits: Rafi KC <rkavunga@redhat.com>
Updates: #208
Change-Id: I1a8d74d1e251f1d6d142f066fc99258025c0bcdd
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-entry-ops.c')
-rw-r--r-- | xlators/storage/posix/src/posix-entry-ops.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index d42a7f76e10..377fece5610 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -57,6 +57,7 @@ #include "posix-aio.h" #include "glusterfs-acl.h" #include "posix-messages.h" +#include "posix-metadata.h" #include "events.h" #include "posix-gfid-path.h" #include "compat-uuid.h" @@ -492,6 +493,8 @@ ignore: goto out; } + posix_set_ctime (frame, this, real_path, -1, loc->inode, &stbuf); + op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path, &postparent, _gf_false); if (op_ret == -1) { @@ -502,6 +505,9 @@ ignore: goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + op_ret = 0; out: @@ -808,6 +814,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_ctime (frame, this, real_path, -1, loc->inode, &stbuf); + op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path, &postparent, _gf_false); if (op_ret == -1) { @@ -818,6 +826,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + op_ret = 0; out: @@ -1222,6 +1233,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + unwind_dict = posix_dict_set_nlink (xdata, unwind_dict, stbuf.ia_nlink); op_ret = 0; out: @@ -1355,6 +1369,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + out: SET_TO_OLD_FS_ID (); @@ -1432,6 +1449,8 @@ posix_symlink (call_frame_t *frame, xlator_t *this, entry_created = _gf_true; + posix_set_ctime (frame, this, real_path, -1, loc->inode, &stbuf); + #ifndef HAVE_SET_FSID op_ret = sys_lchown (real_path, frame->root->uid, gid); if (op_ret == -1) { @@ -1493,6 +1512,9 @@ ignore: goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + op_ret = 0; out: @@ -1778,6 +1800,8 @@ unlock: goto out; } + posix_set_ctime (frame, this, real_newpath, -1, newloc->inode, &stbuf); + op_ret = posix_pstat (this, oldloc->parent, oldloc->pargfid, par_oldpath, &postoldparent, _gf_false); if (op_ret == -1) { @@ -1788,6 +1812,9 @@ unlock: goto out; } + posix_set_parent_ctime (frame, this, par_oldpath, -1, oldloc->parent, + &postoldparent); + op_ret = posix_pstat (this, newloc->parent, newloc->pargfid, par_newpath, &postnewparent, _gf_false); if (op_ret == -1) { @@ -1798,6 +1825,9 @@ unlock: goto out; } + posix_set_parent_ctime (frame, this, par_newpath, -1, newloc->parent, + &postnewparent); + if (was_present) unwind_dict = posix_dict_set_nlink (xdata, unwind_dict, nlink); op_ret = 0; @@ -1899,6 +1929,8 @@ posix_link (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_ctime (frame, this, real_newpath, -1, newloc->inode, &stbuf); + op_ret = posix_pstat (this, newloc->parent, newloc->pargfid, par_newpath, &postparent, _gf_false); if (op_ret == -1) { @@ -1908,6 +1940,9 @@ posix_link (call_frame_t *frame, xlator_t *this, goto out; } + posix_set_parent_ctime (frame, this, par_newpath, -1, newloc->parent, + &postparent); + if (priv->update_pgfid_nlinks) { MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, PGFID_XATTR_KEY_PREFIX, newloc->pargfid); @@ -2120,6 +2155,8 @@ fill_stat: goto out; } + posix_set_ctime (frame, this, real_path, -1, loc->inode, &stbuf); + op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path, &postparent, _gf_false); if (op_ret == -1) { @@ -2130,6 +2167,9 @@ fill_stat: goto out; } + posix_set_parent_ctime (frame, this, par_path, -1, loc->parent, + &postparent); + op_ret = -1; pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd); if (!pfd) { |