summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/storage/posix/src/posix-aio.c51
-rw-r--r--xlators/storage/posix/src/posix-entry-ops.c101
-rw-r--r--xlators/storage/posix/src/posix-handle.c22
-rw-r--r--xlators/storage/posix/src/posix-handle.h8
-rw-r--r--xlators/storage/posix/src/posix-helpers.c60
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c65
-rw-r--r--xlators/storage/posix/src/posix-inode-handle.h5
-rw-r--r--xlators/storage/posix/src/posix-messages.h3
-rw-r--r--xlators/storage/posix/src/posix-metadata.c8
-rw-r--r--xlators/storage/posix/src/posix-metadata.h2
-rw-r--r--xlators/storage/posix/src/posix.h11
11 files changed, 233 insertions, 103 deletions
diff --git a/xlators/storage/posix/src/posix-aio.c b/xlators/storage/posix/src/posix-aio.c
index 47460bc77b4..f8d568becac 100644
--- a/xlators/storage/posix/src/posix-aio.c
+++ b/xlators/storage/posix/src/posix-aio.c
@@ -59,14 +59,15 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags,
struct posix_aio_cb {
- struct iocb iocb;
- call_frame_t *frame;
- struct iobuf *iobuf;
- struct iobref *iobref;
- struct iatt prebuf;
- int fd;
- int op;
- off_t offset;
+ struct iocb iocb;
+ call_frame_t *frame;
+ struct iobuf *iobuf;
+ struct iobref *iobref;
+ struct iatt prebuf;
+ int _fd;
+ fd_t *fd;
+ int op;
+ off_t offset;
};
@@ -85,13 +86,15 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2)
int ret = 0;
off_t offset = 0;
struct posix_private * priv = NULL;
+ fd_t *fd = NULL;
frame = paiocb->frame;
this = frame->this;
priv = this->private;
iobuf = paiocb->iobuf;
- _fd = paiocb->fd;
+ fd = paiocb->fd;
+ _fd = paiocb->_fd;
offset = paiocb->offset;
if (res < 0) {
@@ -105,7 +108,7 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2)
goto out;
}
- ret = posix_fdstat (this, _fd, &postbuf);
+ ret = posix_fdstat (this, fd->inode, _fd, &postbuf);
if (ret != 0) {
op_ret = -1;
op_errno = errno;
@@ -148,6 +151,9 @@ out:
if (iobref)
iobref_unref (iobref);
+ if (paiocb->fd)
+ fd_unref (paiocb->fd);
+
GF_FREE (paiocb);
return 0;
@@ -205,7 +211,8 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
paiocb->frame = frame;
paiocb->iobuf = iobuf;
paiocb->offset = offset;
- paiocb->fd = _fd;
+ paiocb->fd = fd_ref(fd);
+ paiocb->_fd = _fd;
paiocb->op = GF_FOP_READ;
paiocb->iocb.data = paiocb;
@@ -240,8 +247,11 @@ err:
if (iobuf)
iobuf_unref (iobuf);
- if (paiocb)
+ if (paiocb) {
+ if (paiocb->fd)
+ fd_unref(paiocb->fd);
GF_FREE (paiocb);
+ }
return 0;
}
@@ -259,13 +269,15 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2)
int op_errno = 0;
int ret = 0;
struct posix_private * priv = NULL;
+ fd_t *fd = NULL;
frame = paiocb->frame;
this = frame->this;
priv = this->private;
prebuf = paiocb->prebuf;
- _fd = paiocb->fd;
+ fd = paiocb->fd;
+ _fd = paiocb->_fd;
if (res < 0) {
op_ret = -1;
@@ -278,7 +290,7 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2)
goto out;
}
- ret = posix_fdstat (this, _fd, &postbuf);
+ ret = posix_fdstat (this, fd->inode, _fd, &postbuf);
if (ret != 0) {
op_ret = -1;
op_errno = errno;
@@ -304,6 +316,8 @@ out:
if (paiocb) {
if (paiocb->iobref)
iobref_unref (paiocb->iobref);
+ if (paiocb->fd)
+ fd_unref(paiocb->fd);
GF_FREE (paiocb);
}
@@ -318,7 +332,7 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
{
int32_t op_errno = EINVAL;
int _fd = -1;
- struct posix_fd * pfd = NULL;
+ struct posix_fd *pfd = NULL;
int ret = -1;
struct posix_aio_cb *paiocb = NULL;
struct posix_private *priv = NULL;
@@ -349,7 +363,8 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
paiocb->frame = frame;
paiocb->offset = offset;
- paiocb->fd = _fd;
+ paiocb->fd = fd_ref(fd);
+ paiocb->_fd = _fd;
paiocb->op = GF_FOP_WRITE;
paiocb->iocb.data = paiocb;
@@ -363,7 +378,7 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
iocb = &paiocb->iocb;
- ret = posix_fdstat (this, _fd, &paiocb->prebuf);
+ ret = posix_fdstat (this, fd->inode, _fd, &paiocb->prebuf);
if (ret != 0) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED,
@@ -397,6 +412,8 @@ err:
if (paiocb) {
if (paiocb->iobref)
iobref_unref (paiocb->iobref);
+ if (paiocb->fd)
+ fd_unref(paiocb->fd);
GF_FREE (paiocb);
}
diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c
index 438fbe509e4..d42a7f76e10 100644
--- a/xlators/storage/posix/src/posix-entry-ops.c
+++ b/xlators/storage/posix/src/posix-entry-ops.c
@@ -277,7 +277,8 @@ unlock:
parent:
if (par_path) {
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid,
+ par_path, &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -362,7 +363,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -482,7 +484,7 @@ ignore:
}
}
- op_ret = posix_pstat (this, NULL, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, NULL, real_path, &stbuf, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKNOD_FAILED,
@@ -490,7 +492,8 @@ ignore:
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -585,7 +588,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
gid = frame->root->gid;
- op_ret = posix_pstat (this, NULL, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, NULL, real_path, &stbuf, _gf_false);
SET_FS_ID (frame->root->uid, gid);
@@ -603,7 +606,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
}
if (!gf_uuid_is_null (uuid_req)) {
- op_ret = posix_istat (this, uuid_req, NULL, &stbuf);
+ op_ret = posix_istat (this, loc->inode, uuid_req, NULL, &stbuf);
if ((op_ret == 0) && IA_ISDIR (stbuf.ia_type)) {
size = posix_handle_path (this, uuid_req, NULL, NULL,
0);
@@ -647,7 +650,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -796,7 +800,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
gfid_set = _gf_true;
}
- op_ret = posix_pstat (this, NULL, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, NULL, real_path, &stbuf, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -804,7 +808,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -932,7 +937,11 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path,
if (get_link_count) {
LOCK (&loc->inode->lock);
locked = _gf_true;
- ret = posix_pstat (this, loc->gfid, real_path, &prebuf);
+ /* Since this stat is to get link count and not for time
+ * attributes, intentionally passing inode as NULL
+ */
+ ret = posix_pstat (this, NULL, loc->gfid, real_path,
+ &prebuf, _gf_true);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_LSTAT_FAILED, "lstat on %s failed",
@@ -1049,7 +1058,8 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1191,7 +1201,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
}
if (fdstat_requested) {
- op_ret = posix_fdstat (this, fd, &postbuf);
+ op_ret = posix_fdstat (this, loc->inode, fd, &postbuf);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -1202,7 +1212,8 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
op_ret = posix_set_iatt_in_dict (unwind_dict, &postbuf);
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1276,7 +1287,8 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1333,7 +1345,8 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1393,7 +1406,8 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
SET_FS_ID (frame->root->uid, gid);
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1461,7 +1475,7 @@ ignore:
gfid_set = _gf_true;
}
- op_ret = posix_pstat (this, NULL, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, NULL, real_path, &stbuf, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1469,7 +1483,8 @@ ignore:
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1563,7 +1578,8 @@ posix_rename (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &preoldparent);
+ op_ret = posix_pstat (this, oldloc->parent, oldloc->pargfid,
+ par_oldpath, &preoldparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1572,7 +1588,8 @@ posix_rename (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &prenewparent);
+ op_ret = posix_pstat (this, newloc->parent, newloc->pargfid,
+ par_newpath, &prenewparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1581,7 +1598,8 @@ posix_rename (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, NULL, real_newpath, &stbuf);
+ op_ret = posix_pstat (this, newloc->inode, NULL, real_newpath, &stbuf,
+ _gf_false);
if ((op_ret == -1) && (errno == ENOENT)){
was_present = 0;
} else {
@@ -1650,8 +1668,8 @@ posix_rename (call_frame_t *frame, xlator_t *this,
pthread_mutex_lock (&ctx_new->pgfid_lock);
locked = _gf_true;
get_link_count = _gf_true;
- op_ret = posix_pstat (this, newloc->gfid, real_newpath,
- &stbuf);
+ op_ret = posix_pstat (this, newloc->inode, newloc->gfid,
+ real_newpath, &stbuf, _gf_false);
if ((op_ret == -1) && (errno != ENOENT)) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -1751,7 +1769,8 @@ unlock:
oldloc->inode->gfid, NULL);
}
- op_ret = posix_pstat (this, NULL, real_newpath, &stbuf);
+ op_ret = posix_pstat (this, newloc->inode, NULL, real_newpath, &stbuf,
+ _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1759,7 +1778,8 @@ unlock:
goto out;
}
- op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &postoldparent);
+ op_ret = posix_pstat (this, oldloc->parent, oldloc->pargfid,
+ par_oldpath, &postoldparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1768,7 +1788,8 @@ unlock:
goto out;
}
- op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postnewparent);
+ op_ret = posix_pstat (this, newloc->parent, newloc->pargfid,
+ par_newpath, &postnewparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1847,7 +1868,8 @@ posix_link (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &preparent);
+ op_ret = posix_pstat (this, newloc->parent, newloc->pargfid,
+ par_newpath, &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1868,7 +1890,8 @@ posix_link (call_frame_t *frame, xlator_t *this,
entry_created = _gf_true;
- op_ret = posix_pstat (this, NULL, real_newpath, &stbuf);
+ op_ret = posix_pstat (this, newloc->inode, NULL, real_newpath, &stbuf,
+ _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1876,7 +1899,8 @@ posix_link (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postparent);
+ op_ret = posix_pstat (this, newloc->parent, newloc->pargfid,
+ par_newpath, &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1996,7 +2020,8 @@ posix_create (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -2016,7 +2041,8 @@ posix_create (call_frame_t *frame, xlator_t *this,
_flags = flags | O_CREAT;
}
- op_ret = posix_pstat (this, NULL, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, NULL, real_path, &stbuf,
+ _gf_false);
if ((op_ret == -1) && (errno == ENOENT)) {
was_present = 0;
}
@@ -2086,7 +2112,7 @@ fill_stat:
gfid_set = _gf_true;
}
- op_ret = posix_fdstat (this, _fd, &stbuf);
+ op_ret = posix_fdstat (this, loc->inode, _fd, &stbuf);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -2094,7 +2120,8 @@ fill_stat:
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -2170,7 +2197,8 @@ posix_put (call_frame_t *frame, xlator_t *this, loc_t *loc,
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf);
- op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &preparent, _gf_false);
if (op_ret < 0) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -2199,7 +2227,8 @@ posix_put (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto out;
}
- op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
+ op_ret = posix_pstat (this, loc->parent, loc->pargfid, par_path,
+ &postparent, _gf_false);
if (op_ret < 0) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -2233,7 +2262,7 @@ posix_put (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto out;
}
- op_ret = posix_pstat (this, loc->gfid, real_path, &stbuf);
+ op_ret = posix_pstat (this, loc->inode, loc->gfid, real_path, &stbuf, _gf_false);
if (op_ret < 0) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index a3a8ea464d3..0bb4c055a3c 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -23,6 +23,7 @@
#include "xlator.h"
#include "syscall.h"
#include "posix-messages.h"
+#include "posix-metadata.h"
#include "compat-errno.h"
@@ -36,7 +37,7 @@ posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
inode_t *inode = NULL;
int ret = -1;
- ret = posix_istat (this, parent->gfid, bname, iabuf);
+ ret = posix_istat (this, NULL, parent->gfid, bname, iabuf);
if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING, "gfid: %s, bname: %s "
"failed", uuid_utoa (parent->gfid), bname);
@@ -53,6 +54,19 @@ posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
}
}
+ /* posix_istat wouldn't have fetched posix_mdata_t i.e.,
+ * time attributes as inode is passed as NULL, hence get
+ * here once you got the inode
+ */
+ ret = posix_get_mdata_xattr (this, NULL, -1, inode, iabuf);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_GETMDATA_FAILED,
+ "posix get mdata failed on gfid:%s",
+ uuid_utoa (inode->gfid));
+ goto out;
+ }
+
/* Linking an inode here, can cause a race in posix_acl.
Parent inode gets linked here, but before
it reaches posix_acl_readdirp_cbk, create/lookup can
@@ -939,8 +953,10 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename)
return -1;
}
- ret = posix_istat (this, gfid, basename, &stat);
-
+ /* stat is being used only for gfid, so passing a NULL inode
+ * doesn't fetch time attributes which is fine
+ */
+ ret = posix_istat (this, NULL, gfid, basename, &stat);
if (ret == -1) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_DELETE, "%s", path);
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index 78da75d5358..b12e8b9610c 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -146,17 +146,19 @@
MAKE_REAL_PATH (entp, this, loc->path); \
__parp = strdupa (entp); \
parp = dirname (__parp); \
- op_ret = posix_pstat (this, NULL, entp, ent_p); \
+ op_ret = posix_pstat (this, loc->inode, NULL, entp, ent_p, \
+ _gf_false); \
break; \
} \
errno = 0; \
- op_ret = posix_istat (this, loc->pargfid, loc->name, ent_p); \
+ op_ret = posix_istat (this, loc->inode, loc->pargfid, \
+ loc->name, ent_p); \
if (errno != ELOOP) { \
MAKE_HANDLE_PATH (parp, this, loc->pargfid, NULL); \
MAKE_HANDLE_PATH (entp, this, loc->pargfid, loc->name); \
if (!parp || !entp) { \
gf_msg (this->name, GF_LOG_ERROR, errno, \
- P_MSG_ENTRY_HANDLE_CREATE, \
+ P_MSG_ENTRY_HANDLE_CREATE, \
"Failed to create entry handle " \
"for path %s", loc->path); \
} \
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index e9d379fda07..6a34e38cbbc 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -39,6 +39,7 @@
#include "logging.h"
#include "posix.h"
#include "posix-messages.h"
+#include "posix-metadata.h"
#include "posix-handle.h"
#include "xlator.h"
#include "defaults.h"
@@ -600,7 +601,7 @@ out:
}
int
-posix_fdstat (xlator_t *this, int fd, struct iatt *stbuf_p)
+posix_fdstat (xlator_t *this, inode_t *inode, int fd, struct iatt *stbuf_p)
{
int ret = 0;
struct stat fstatbuf = {0, };
@@ -615,6 +616,16 @@ posix_fdstat (xlator_t *this, int fd, struct iatt *stbuf_p)
iatt_from_stat (&stbuf, &fstatbuf);
+ if (inode && is_ctime_enabled()) {
+ ret = posix_get_mdata_xattr (this, NULL, fd, inode, &stbuf);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_GETMDATA_FAILED,
+ "posix get mdata failed on gfid: %s",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
+ }
ret = posix_fill_gfid_fd (this, fd, &stbuf);
stbuf.ia_flags |= IATT_GFID;
@@ -628,8 +639,12 @@ out:
}
+/* The inode here is expected to update posix_mdata stored on disk.
+ * Don't use it as a general purpose inode and don't expect it to
+ * be always exists
+ */
int
-posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
+posix_istat (xlator_t *this, inode_t *inode, uuid_t gfid, const char *basename,
struct iatt *buf_p)
{
char *real_path = NULL;
@@ -683,6 +698,17 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
iatt_from_stat (&stbuf, &lstatbuf);
+ if (inode && is_ctime_enabled()) {
+ ret = posix_get_mdata_xattr (this, real_path, -1, inode,
+ &stbuf);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_GETMDATA_FAILED,
+ "posix get mdata failed on %s", real_path);
+ goto out;
+ }
+ }
+
if (basename)
posix_fill_gfid_path (this, real_path, &stbuf);
else
@@ -700,8 +726,8 @@ out:
int
-posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
- struct iatt *buf_p)
+posix_pstat (xlator_t *this, inode_t *inode, uuid_t gfid, const char *path,
+ struct iatt *buf_p, gf_boolean_t inode_locked)
{
struct stat lstatbuf = {0, };
struct iatt stbuf = {0, };
@@ -740,6 +766,21 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
iatt_from_stat (&stbuf, &lstatbuf);
+ if (inode && is_ctime_enabled()) {
+ if (!inode_locked) {
+ ret = posix_get_mdata_xattr (this, path, -1, inode, &stbuf);
+ } else {
+ ret = __posix_get_mdata_xattr (this, path, -1, inode, &stbuf);
+ }
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_GETMDATA_FAILED,
+ "posix get mdata failed on gfid: %s",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
+ }
+
posix_fill_ino_from_gfid (this, &stbuf);
if (buf_p)
@@ -1033,7 +1074,11 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
goto out;
}
- op_ret = posix_istat (this, pargfid, name, &stbuf);
+ /* TODO: Not fetching posix_mdata_t. This is fine without
+ * RIO as this routine is only interested in file contents.
+ * Need to check how does this function fits into RIO?
+ */
+ op_ret = posix_istat (this, NULL, pargfid, name, &stbuf);
if (op_ret == -1) {
op_ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
@@ -1377,7 +1422,10 @@ janitor_walker (const char *fpath, const struct stat *sb,
xlator_t *this = NULL;
this = THIS;
- posix_pstat (this, NULL, fpath, &stbuf);
+ /* posix_mdata_t is not filled, no time or size attributes
+ * are being used, so fine.
+ */
+ posix_pstat (this, NULL, NULL, fpath, &stbuf, _gf_false);
switch (sb->st_mode & S_IFMT) {
case S_IFREG:
case S_IFBLK:
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 4aa70baf3bd..c6145e880f4 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -386,7 +386,8 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = posix_pstat (this, loc->gfid, real_path, &statpost);
+ op_ret = posix_pstat (this, loc->inode, loc->gfid, real_path,
+ &statpost, _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -519,7 +520,7 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_fdstat (this, pfd->fd, &statpre);
+ op_ret = posix_fdstat (this, fd->inode, pfd->fd, &statpre);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -574,7 +575,7 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = posix_fdstat (this, pfd->fd, &statpost);
+ op_ret = posix_fdstat (this, fd->inode, pfd->fd, &statpost);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -648,7 +649,7 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
pthread_mutex_lock (&ctx->write_atomic_lock);
}
- ret = posix_fdstat (this, pfd->fd, statpre);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, statpre);
if (ret == -1) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -677,7 +678,7 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto out;
}
- ret = posix_fdstat (this, pfd->fd, statpost);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, statpost);
if (ret == -1) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -830,7 +831,7 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
pthread_mutex_lock (&ctx->write_atomic_lock);
}
- ret = posix_fdstat (this, pfd->fd, statpre);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, statpre);
if (ret == -1) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -878,7 +879,7 @@ fsync:
}
}
- ret = posix_fdstat (this, pfd->fd, statpost);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, statpost);
if (ret == -1) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -1044,7 +1045,7 @@ posix_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
}
if (xdata) {
- ret = posix_fdstat (this, pfd->fd, &preop);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, &preop);
if (ret == -1) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -1296,7 +1297,8 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
goto out;
}
- op_ret = posix_pstat (this, loc->gfid, real_path, &postbuf);
+ op_ret = posix_pstat (this, loc->inode, loc->gfid, real_path, &postbuf,
+ _gf_false);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
@@ -1455,7 +1457,7 @@ posix_readv (call_frame_t *frame, xlator_t *this,
_fd = pfd->fd;
if (xdata) {
- op_ret = posix_fdstat (this, _fd, &preop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &preop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -1501,7 +1503,7 @@ posix_readv (call_frame_t *frame, xlator_t *this,
* we read from
*/
- op_ret = posix_fdstat (this, _fd, &stbuf);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &stbuf);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -1749,7 +1751,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
pthread_mutex_lock (&ctx->write_atomic_lock);
}
- op_ret = posix_fdstat (this, _fd, &preop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &preop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -1795,7 +1797,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
* the file we wrote to
*/
- ret = posix_fdstat (this, _fd, &postop);
+ ret = posix_fdstat (this, fd->inode, _fd, &postop);
if (ret == -1) {
op_ret = -1;
op_errno = errno;
@@ -2069,7 +2071,7 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
_fd = pfd->fd;
- op_ret = posix_fdstat (this, _fd, &preop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &preop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED,
@@ -2097,7 +2099,7 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = posix_fdstat (this, _fd, &postop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &postop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED,
@@ -2187,7 +2189,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
goto out;
}
- posix_pstat(this, loc->gfid, real_path, &stbuf);
+ posix_pstat(this, loc->inode, loc->gfid, real_path, &stbuf, _gf_false);
op_ret = -1;
@@ -2213,7 +2215,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
goto unlock;
}
- ret = posix_pstat (this, NULL, real_path, &tmp_stbuf);
+ ret = posix_pstat (this, loc->inode, loc->gfid, real_path,
+ &tmp_stbuf, _gf_true);
if (ret) {
op_errno = EINVAL;
goto unlock;
@@ -2316,7 +2319,8 @@ unlock:
* Ignore errors for now
*/
if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) {
- ret = posix_pstat(this, loc->gfid, real_path, &stbuf);
+ ret = posix_pstat(this, loc->inode, loc->gfid, real_path,
+ &stbuf, _gf_false);
if (ret)
goto out;
@@ -3702,7 +3706,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
}
_fd = pfd->fd;
- ret = posix_fdstat (this, pfd->fd, &stbuf);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, &stbuf);
if (ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, op_errno,
@@ -3742,7 +3746,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
}
if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) {
- ret = posix_fdstat (this, pfd->fd, &stbuf);
+ ret = posix_fdstat (this, fd->inode, pfd->fd, &stbuf);
if (ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, op_errno,
@@ -3924,9 +3928,10 @@ posix_common_removexattr (call_frame_t *frame, loc_t *loc, fd_t *fd,
if (xdata && dict_get (xdata, DHT_IATT_IN_XDATA_KEY)) {
if (loc)
- ret = posix_pstat(this, loc->gfid, real_path, &stbuf);
+ ret = posix_pstat(this, inode, loc->gfid,
+ real_path, &stbuf, _gf_false);
else
- ret = posix_fdstat (this, _fd, &stbuf);
+ ret = posix_fdstat (this, inode, _fd, &stbuf);
if (ret)
goto out;
*xdata_rsp = dict_new();
@@ -4425,10 +4430,10 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
goto out;
if (fd) {
- op_ret = posix_fdstat (this, _fd, &stbuf);
+ op_ret = posix_fdstat (this, inode, _fd, &stbuf);
} else {
- op_ret = posix_pstat (this, inode->gfid, real_path,
- &stbuf);
+ op_ret = posix_pstat (this, inode, inode->gfid, real_path,
+ &stbuf, _gf_false);
}
if (op_ret < 0) {
op_errno = errno;
@@ -4544,7 +4549,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
_fd = pfd->fd;
- op_ret = posix_fdstat (this, _fd, &preop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &preop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -4572,7 +4577,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = posix_fdstat (this, _fd, &postop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &postop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -4627,7 +4632,7 @@ posix_fstat (call_frame_t *frame, xlator_t *this,
_fd = pfd->fd;
- op_ret = posix_fdstat (this, _fd, &buf);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &buf);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
@@ -4992,7 +4997,7 @@ posix_readdirp_fill (xlator_t *this, fd_t *fd, gf_dirent_t *entries, dict_t *dic
strcpy (&hpath[len+1], entry->d_name);
- ret = posix_pstat (this, gfid, hpath, &stbuf);
+ ret = posix_pstat (this, inode, gfid, hpath, &stbuf, _gf_false);
if (ret == -1) {
if (inode)
@@ -5205,7 +5210,7 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
_fd = pfd->fd;
if (xdata) {
- op_ret = posix_fdstat (this, _fd, &preop);
+ op_ret = posix_fdstat (this, fd->inode, _fd, &preop);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
diff --git a/xlators/storage/posix/src/posix-inode-handle.h b/xlators/storage/posix/src/posix-inode-handle.h
index b6cb871e007..33d908fa3de 100644
--- a/xlators/storage/posix/src/posix-inode-handle.h
+++ b/xlators/storage/posix/src/posix-inode-handle.h
@@ -69,11 +69,12 @@
} \
if (LOC_IS_DIR (loc) && LOC_HAS_ABSPATH (loc)) { \
MAKE_REAL_PATH (rpath, this, (loc)->path); \
- op_ret = posix_pstat (this, (loc)->gfid, rpath, iatt_p); \
+ op_ret = posix_pstat (this, (loc)->inode, (loc)->gfid, \
+ rpath, iatt_p, _gf_false); \
break; \
} \
errno = 0; \
- op_ret = posix_istat (this, loc->gfid, NULL, iatt_p); \
+ op_ret = posix_istat (this, loc->inode, loc->gfid, NULL, iatt_p); \
if (errno != ELOOP) { \
MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL); \
if (!rpath) { \
diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h
index 6b5332b6d09..b83a7b18809 100644
--- a/xlators/storage/posix/src/posix-messages.h
+++ b/xlators/storage/posix/src/posix-messages.h
@@ -138,7 +138,8 @@ GLFS_MSGID(POSIX,
P_MSG_DISK_SPACE_CHECK_FAILED,
P_MSG_FALLOCATE_FAILED,
P_MSG_STOREMDATA_FAILED,
- P_MSG_FETCHMDATA_FAILED
+ P_MSG_FETCHMDATA_FAILED,
+ P_MSG_GETMDATA_FAILED
);
#endif /* !_GLUSTERD_MESSAGES_H_ */
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c
index 4e75a4f1411..57f32f9359c 100644
--- a/xlators/storage/posix/src/posix-metadata.c
+++ b/xlators/storage/posix/src/posix-metadata.c
@@ -508,3 +508,11 @@ posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd,
&flag);
return ret;
}
+
+gf_boolean_t
+is_ctime_enabled () {
+ /* TODO: This gets implemented once glusterd changes are in place to
+ * * enable and disable ctime feature
+ * */
+ return _gf_false;
+}
diff --git a/xlators/storage/posix/src/posix-metadata.h b/xlators/storage/posix/src/posix-metadata.h
index b654c83230c..a6bde785abe 100644
--- a/xlators/storage/posix/src/posix-metadata.h
+++ b/xlators/storage/posix/src/posix-metadata.h
@@ -45,5 +45,7 @@ posix_set_mdata_xattr (xlator_t *this, const char *real_path, int fd,
int
posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd,
inode_t *inode, struct iatt *stbuf, int valid);
+gf_boolean_t
+is_ctime_enabled();
#endif /* _POSIX_METADATA_H */
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 60a7132ddcb..9712b675eb1 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -327,11 +327,12 @@ int __posix_inode_ctx_get_all (inode_t *inode, xlator_t *this,
int posix_gfid_set (xlator_t *this, const char *path, loc_t *loc,
dict_t *xattr_req);
-int posix_fdstat (xlator_t *this, int fd, struct iatt *stbuf_p);
-int posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
- struct iatt *iatt);
-int posix_pstat (xlator_t *this, uuid_t gfid, const char *real_path,
- struct iatt *iatt);
+int posix_fdstat (xlator_t *this, inode_t *inode, int fd, struct iatt *stbuf_p);
+int posix_istat (xlator_t *this, inode_t *inode, uuid_t gfid,
+ const char *basename, struct iatt *iatt);
+int posix_pstat (xlator_t *this, inode_t *inode, uuid_t gfid,
+ const char *real_path, struct iatt *iatt,
+ gf_boolean_t inode_locked);
dict_t *posix_xattr_fill (xlator_t *this, const char *path, loc_t *loc,
fd_t *fd, int fdnum, dict_t *xattr, struct iatt *buf);
int posix_handle_pair (xlator_t *this, const char *real_path, char *key,