/extras/init.d/

>
summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse/src/fuse-bridge.c
diff options
context:
space:
mode:
authorGluster Ant <bugzilla-bot@gluster.org>2018-09-12 17:52:45 +0530
committerNigel Babu <nigelb@redhat.com>2018-09-12 17:52:45 +0530
commite16868dede6455cab644805af6fe1ac312775e13 (patch)
tree15aebdb4fff2d87cf8a72f836816b3aa634da58d /xlators/mount/fuse/src/fuse-bridge.c
parent45a71c0548b6fd2c757aa2e7b7671a1411948894 (diff)
Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
Diffstat (limited to 'xlators/mount/fuse/src/fuse-bridge.c')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c9339
1 files changed, 4595 insertions, 4744 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index cd163781462..e4e64dd4a96 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -22,9 +22,11 @@
static int gf_fuse_xattr_enotsup_log;
-void fini (xlator_t *this_xl);
+void
+fini(xlator_t *this_xl);
-static void fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino);
+static void
+fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino);
/*
* Send an invalidate notification up to fuse to purge the file from local
@@ -34,218 +36,220 @@ static void fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino);
static int32_t
fuse_invalidate(xlator_t *this, inode_t *inode)
{
- fuse_private_t *priv = this->private;
- uint64_t nodeid;
+ fuse_private_t *priv = this->private;
+ uint64_t nodeid;
- /*
- * NOTE: We only invalidate at the moment if fopen_keep_cache is
- * enabled because otherwise this is a departure from default
- * behavior. Specifically, the performance/write-behind xlator
- * causes unconditional invalidations on write requests.
- */
- if (!priv->fopen_keep_cache)
- return 0;
+ /*
+ * NOTE: We only invalidate at the moment if fopen_keep_cache is
+ * enabled because otherwise this is a departure from default
+ * behavior. Specifically, the performance/write-behind xlator
+ * causes unconditional invalidations on write requests.
+ */
+ if (!priv->fopen_keep_cache)
+ return 0;
- nodeid = inode_to_fuse_nodeid(inode);
- gf_log(this->name, GF_LOG_DEBUG, "Invalidate inode id %"GF_PRI_INODE"." , nodeid);
- fuse_log_eh (this, "Sending invalidate inode id: %"GF_PRI_INODE" gfid: %s", nodeid,
- uuid_utoa (inode->gfid));
- fuse_invalidate_inode(this, nodeid);
+ nodeid = inode_to_fuse_nodeid(inode);
+ gf_log(this->name, GF_LOG_DEBUG, "Invalidate inode id %" GF_PRI_INODE ".",
+ nodeid);
+ fuse_log_eh(this, "Sending invalidate inode id: %" GF_PRI_INODE " gfid: %s",
+ nodeid, uuid_utoa(inode->gfid));
+ fuse_invalidate_inode(this, nodeid);
- return 0;
+ return 0;
}
static int32_t
-fuse_forget_cbk (xlator_t *this, inode_t *inode)
+fuse_forget_cbk(xlator_t *this, inode_t *inode)
{
- //Nothing to free in inode ctx, hence return.
- return 0;
+ // Nothing to free in inode ctx, hence return.
+ return 0;
}
fuse_fd_ctx_t *
-__fuse_fd_ctx_check_n_create (xlator_t *this, fd_t *fd)
+__fuse_fd_ctx_check_n_create(xlator_t *this, fd_t *fd)
{
- uint64_t val = 0;
- int32_t ret = 0;
- fuse_fd_ctx_t *fd_ctx = NULL;
+ uint64_t val = 0;
+ int32_t ret = 0;
+ fuse_fd_ctx_t *fd_ctx = NULL;
- ret = __fd_ctx_get (fd, this, &val);
+ ret = __fd_ctx_get(fd, this, &val);
- fd_ctx = (fuse_fd_ctx_t *)(unsigned long) val;
+ fd_ctx = (fuse_fd_ctx_t *)(unsigned long)val;
- if (fd_ctx == NULL) {
- fd_ctx = GF_CALLOC (1, sizeof (*fd_ctx),
- gf_fuse_mt_fd_ctx_t);
- if (!fd_ctx) {
- goto out;
- }
- ret = __fd_ctx_set (fd, this,
- (uint64_t)(unsigned long)fd_ctx);
- if (ret < 0) {
- gf_log ("glusterfs-fuse", GF_LOG_DEBUG,
- "fd-ctx-set failed");
- GF_FREE (fd_ctx);
- fd_ctx = NULL;
- }
+ if (fd_ctx == NULL) {
+ fd_ctx = GF_CALLOC(1, sizeof(*fd_ctx), gf_fuse_mt_fd_ctx_t);
+ if (!fd_ctx) {
+ goto out;
+ }
+ ret = __fd_ctx_set(fd, this, (uint64_t)(unsigned long)fd_ctx);
+ if (ret < 0) {
+ gf_log("glusterfs-fuse", GF_LOG_DEBUG, "fd-ctx-set failed");
+ GF_FREE(fd_ctx);
+ fd_ctx = NULL;
}
+ }
out:
- return fd_ctx;
+ return fd_ctx;
}
fuse_fd_ctx_t *
-fuse_fd_ctx_check_n_create (xlator_t *this, fd_t *fd)
+fuse_fd_ctx_check_n_create(xlator_t *this, fd_t *fd)
{
- fuse_fd_ctx_t *fd_ctx = NULL;
+ fuse_fd_ctx_t *fd_ctx = NULL;
- if ((fd == NULL) || (this == NULL)) {
- goto out;
- }
+ if ((fd == NULL) || (this == NULL)) {
+ goto out;
+ }
- LOCK (&fd->lock);
- {
- fd_ctx = __fuse_fd_ctx_check_n_create (this, fd);
- }
- UNLOCK (&fd->lock);
+ LOCK(&fd->lock);
+ {
+ fd_ctx = __fuse_fd_ctx_check_n_create(this, fd);
+ }
+ UNLOCK(&fd->lock);
out:
- return fd_ctx;
+ return fd_ctx;
}
static void
-fuse_fd_ctx_destroy (xlator_t *this, fd_t *fd)
-{
- fd_t *activefd = NULL;
- uint64_t val = 0;
- int ret = 0;
- fuse_fd_ctx_t *fdctx = NULL;
-
- ret = fd_ctx_del (fd, this, &val);
- if (!ret) {
- fdctx = (fuse_fd_ctx_t *)(unsigned long)val;
- if (fdctx) {
- activefd = fdctx->activefd;
- if (activefd) {
- fd_unref (activefd);
- }
-
- GF_FREE (fdctx);
- }
+fuse_fd_ctx_destroy(xlator_t *this, fd_t *fd)
+{
+ fd_t *activefd = NULL;
+ uint64_t val = 0;
+ int ret = 0;
+ fuse_fd_ctx_t *fdctx = NULL;
+
+ ret = fd_ctx_del(fd, this, &val);
+ if (!ret) {
+ fdctx = (fuse_fd_ctx_t *)(unsigned long)val;
+ if (fdctx) {
+ activefd = fdctx->activefd;
+ if (activefd) {
+ fd_unref(activefd);
+ }
+
+ GF_FREE(fdctx);
}
+ }
}
fuse_fd_ctx_t *
-fuse_fd_ctx_get (xlator_t *this, fd_t *fd)
+fuse_fd_ctx_get(xlator_t *this, fd_t *fd)
{
- fuse_fd_ctx_t *fdctx = NULL;
- uint64_t value = 0;
- int ret = 0;
+ fuse_fd_ctx_t *fdctx = NULL;
+ uint64_t value = 0;
+ int ret = 0;
- ret = fd_ctx_get (fd, this, &value);
- if (ret < 0) {
- goto out;
- }
+ ret = fd_ctx_get(fd, this, &value);
+ if (ret < 0) {
+ goto out;
+ }
- fdctx = (fuse_fd_ctx_t *) (unsigned long)value;
+ fdctx = (fuse_fd_ctx_t *)(unsigned long)value;
out:
- return fdctx;
+ return fdctx;
}
-
struct fusedump_timespec {
- uint32_t len;
- uint64_t sec;
- uint32_t nsec;
+ uint32_t len;
+ uint64_t sec;
+ uint32_t nsec;
} __attribute__((packed));
struct fusedump_signature {
- uint32_t len;
- char sig[8];
+ uint32_t len;
+ char sig[8];
} __attribute__((packed));
static void
-fusedump_gettime (struct fusedump_timespec *fts)
+fusedump_gettime(struct fusedump_timespec *fts)
{
- struct timespec ts = {0,};
+ struct timespec ts = {
+ 0,
+ };
- clock_gettime (CLOCK_REALTIME, &ts);
+ clock_gettime(CLOCK_REALTIME, &ts);
- fts->sec = ts.tv_sec;
- fts->nsec = ts.tv_nsec;
+ fts->sec = ts.tv_sec;
+ fts->nsec = ts.tv_nsec;
}
static void
-fusedump_setup_meta (struct iovec *iovs, char *dir,
- uint32_t *fusedump_item_count,
- struct fusedump_timespec *fts,
- struct fusedump_signature *fsig)
+fusedump_setup_meta(struct iovec *iovs, char *dir,
+ uint32_t *fusedump_item_count,
+ struct fusedump_timespec *fts,
+ struct fusedump_signature *fsig)
{
- char glustersig[8] = {'G', 'L', 'U', 'S', 'T', 'E', 'R', 0xF5};
+ char glustersig[8] = {'G', 'L', 'U', 'S', 'T', 'E', 'R', 0xF5};
- *fusedump_item_count = 3;
- fts->len = sizeof (*fts);
- fusedump_gettime (fts);
- fsig->len = sizeof (*fsig);
- memcpy (fsig->sig, glustersig, 8);
+ *fusedump_item_count = 3;
+ fts->len = sizeof(*fts);
+ fusedump_gettime(fts);
+ fsig->len = sizeof(*fsig);
+ memcpy(fsig->sig, glustersig, 8);
- iovs[0] = (struct iovec){ dir, sizeof (*dir) };
- iovs[1] = (struct iovec){ fusedump_item_count,
- sizeof (*fusedump_item_count) };
- iovs[2] = (struct iovec){ fts, fts->len };
- iovs[3] = (struct iovec){ fsig, fsig->len };
+ iovs[0] = (struct iovec){dir, sizeof(*dir)};
+ iovs[1] = (struct iovec){fusedump_item_count, sizeof(*fusedump_item_count)};
+ iovs[2] = (struct iovec){fts, fts->len};
+ iovs[3] = (struct iovec){fsig, fsig->len};
}
static int
-check_and_dump_fuse_W (fuse_private_t *priv, struct iovec *iov_out, int count,
- ssize_t res)
+check_and_dump_fuse_W(fuse_private_t *priv, struct iovec *iov_out, int count,
+ ssize_t res)
{
- char w = 'W';
- struct iovec diov[4] = {{0,},};
- uint32_t fusedump_item_count = 3;
- struct fusedump_timespec fts = {0,};
- struct fusedump_signature fsig = {0,};
- struct fuse_out_header *fouh = NULL;
-
- if (res == -1) {
- gf_log ("glusterfs-fuse", GF_LOG_ERROR,
- "writing to fuse device failed: %s",
- strerror (errno));
- return errno;
- }
-
- fouh = iov_out[0].iov_base;
- if (res != fouh->len) {
- gf_log ("glusterfs-fuse", GF_LOG_ERROR,
- "inconsistent write to fuse device: "
- "written %zd, expectd %d",
- res, fouh->len);
- return EINVAL;
- }
-
- if (priv->fuse_dump_fd == -1)
- return 0;
+ char w = 'W';
+ struct iovec diov[4] = {
+ {
+ 0,
+ },
+ };
+ uint32_t fusedump_item_count = 3;
+ struct fusedump_timespec fts = {
+ 0,
+ };
+ struct fusedump_signature fsig = {
+ 0,
+ };
+ struct fuse_out_header *fouh = NULL;
+
+ if (res == -1) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "writing to fuse device failed: %s", strerror(errno));
+ return errno;
+ }
+
+ fouh = iov_out[0].iov_base;
+ if (res != fouh->len) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "inconsistent write to fuse device: "
+ "written %zd, expectd %d",
+ res, fouh->len);
+ return EINVAL;
+ }
+
+ if (priv->fuse_dump_fd == -1)
+ return 0;
- fusedump_setup_meta (diov, &w, &fusedump_item_count,
- &fts, &fsig);
+ fusedump_setup_meta(diov, &w, &fusedump_item_count, &fts, &fsig);
- pthread_mutex_lock (&priv->fuse_dump_mutex);
- res = sys_writev (priv->fuse_dump_fd, diov,
- sizeof (diov)/sizeof (diov[0]));
- if (res != -1)
- res = sys_writev (priv->fuse_dump_fd, iov_out, count);
- pthread_mutex_unlock (&priv->fuse_dump_mutex);
+ pthread_mutex_lock(&priv->fuse_dump_mutex);
+ res = sys_writev(priv->fuse_dump_fd, diov, sizeof(diov) / sizeof(diov[0]));
+ if (res != -1)
+ res = sys_writev(priv->fuse_dump_fd, iov_out, count);
+ pthread_mutex_unlock(&priv->fuse_dump_mutex);
- if (res == -1)
- gf_log ("glusterfs-fuse", GF_LOG_ERROR,
- "failed to dump fuse message (W): %s",
- strerror (errno));
+ if (res == -1)
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "failed to dump fuse message (W): %s", strerror(errno));
- /*
- * Return value reflects check on write to /dev/fuse,
- * so ignore issues with dumping.
- */
+ /*
+ * Return value reflects check on write to /dev/fuse,
+ * so ignore issues with dumping.
+ */
- return 0;
+ return 0;
}
/*
@@ -253,123 +257,126 @@ check_and_dump_fuse_W (fuse_private_t *priv, struct iovec *iov_out, int count,
* The error value of this header is sent to kernel.
*/
static int
-send_fuse_iov (xlator_t *this, fuse_in_header_t *finh, struct iovec *iov_out,
- int count)
+send_fuse_iov(xlator_t *this, fuse_in_header_t *finh, struct iovec *iov_out,
+ int count)
{
- fuse_private_t *priv = NULL;
- struct fuse_out_header *fouh = NULL;
- int res, i;
+ fuse_private_t *priv = NULL;
+ struct fuse_out_header *fouh = NULL;
+ int res, i;
- if (!this || !finh || !iov_out) {
- gf_log ("send_fuse_iov", GF_LOG_ERROR,"Invalid arguments");
- return EINVAL;
- }
- priv = this->private;
+ if (!this || !finh || !iov_out) {
+ gf_log("send_fuse_iov", GF_LOG_ERROR, "Invalid arguments");
+ return EINVAL;
+ }
+ priv = this->private;
- fouh = iov_out[0].iov_base;
- iov_out[0].iov_len = sizeof (*fouh);
- fouh->len = 0;
- for (i = 0; i < count; i++)
- fouh->len += iov_out[i].iov_len;
- fouh->unique = finh->unique;
+ fouh = iov_out[0].iov_base;
+ iov_out[0].iov_len = sizeof(*fouh);
+ fouh->len = 0;
+ for (i = 0; i < count; i++)
+ fouh->len += iov_out[i].iov_len;
+ fouh->unique = finh->unique;
- res = sys_writev (priv->fd, iov_out, count);
- gf_log ("glusterfs-fuse", GF_LOG_TRACE, "writev() result %d/%d %s",
- res, fouh->len, res == -1 ? strerror (errno) : "");
+ res = sys_writev(priv->fd, iov_out, count);
+ gf_log("glusterfs-fuse", GF_LOG_TRACE, "writev() result %d/%d %s", res,
+ fouh->len, res == -1 ? strerror(errno) : "");
- return check_and_dump_fuse_W (priv, iov_out, count, res);
+ return check_and_dump_fuse_W(priv, iov_out, count, res);
}
static int
-send_fuse_data (xlator_t *this, fuse_in_header_t *finh, void *data, size_t size)
+send_fuse_data(xlator_t *this, fuse_in_header_t *finh, void *data, size_t size)
{
- struct fuse_out_header fouh = {0, };
- struct iovec iov_out[2];
- int ret = 0;
+ struct fuse_out_header fouh = {
+ 0,
+ };
+ struct iovec iov_out[2];
+ int ret = 0;
- fouh.error = 0;
- iov_out[0].iov_base = &fouh;
- iov_out[1].iov_base = data;
- iov_out[1].iov_len = size;
+ fouh.error = 0;
+ iov_out[0].iov_base = &fouh;
+ iov_out[1].iov_base = data;
+ iov_out[1].iov_len = size;
- ret = send_fuse_iov (this, finh, iov_out, 2);
- if (ret != 0)
- gf_log ("glusterfs-fuse", GF_LOG_ERROR, "send_fuse_iov() "
- "failed: %s", strerror (ret));
+ ret = send_fuse_iov(this, finh, iov_out, 2);
+ if (ret != 0)
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "send_fuse_iov() "
+ "failed: %s",
+ strerror(ret));
- return ret;
+ return ret;
}
-#define send_fuse_obj(this, finh, obj) \
- send_fuse_data (this, finh, obj, sizeof (*(obj)))
-
+#define send_fuse_obj(this, finh, obj) \
+ send_fuse_data(this, finh, obj, sizeof(*(obj)))
#if FUSE_KERNEL_MINOR_VERSION >= 11
static void
-fuse_invalidate_entry (xlator_t *this, uint64_t fuse_ino)
+fuse_invalidate_entry(xlator_t *this, uint64_t fuse_ino)
{
- struct fuse_out_header *fouh = NULL;
- struct fuse_notify_inval_entry_out *fnieo = NULL;
- fuse_private_t *priv = NULL;
- dentry_t *dentry = NULL;
- inode_t *inode = NULL;
- size_t nlen = 0;
- fuse_invalidate_node_t *node = NULL;
+ struct fuse_out_header *fouh = NULL;
+ struct fuse_notify_inval_entry_out *fnieo = NULL;
+ fuse_private_t *priv = NULL;
+ dentry_t *dentry = NULL;
+ inode_t *inode = NULL;
+ size_t nlen = 0;
+ fuse_invalidate_node_t *node = NULL;
- priv = this->private;
+ priv = this->private;
- if (!priv->reverse_fuse_thread_started)
- return;
+ if (!priv->reverse_fuse_thread_started)
+ return;
- inode = fuse_ino_to_inode(fuse_ino, this);
- if (inode == NULL) {
- return;
- }
+ inode = fuse_ino_to_inode(fuse_ino, this);
+ if (inode == NULL) {
+ return;
+ }
- list_for_each_entry (dentry, &inode->dentry_list, inode_list) {
- node = GF_CALLOC (1, sizeof (*node),
- gf_fuse_mt_invalidate_node_t);
- if (node == NULL)
- break;
+ list_for_each_entry(dentry, &inode->dentry_list, inode_list)
+ {
+ node = GF_CALLOC(1, sizeof(*node), gf_fuse_mt_invalidate_node_t);
+ if (node == NULL)
+ break;
- INIT_LIST_HEAD (&node->next);
+ INIT_LIST_HEAD(&node->next);
- fouh = (struct fuse_out_header *)node->inval_buf;
- fnieo = (struct fuse_notify_inval_entry_out *)(fouh + 1);
+ fouh = (struct fuse_out_header *)node->inval_buf;
+ fnieo = (struct fuse_notify_inval_entry_out *)(fouh + 1);
- fouh->unique = 0;
- fouh->error = FUSE_NOTIFY_INVAL_ENTRY;
+ fouh->unique = 0;
+ fouh->error = FUSE_NOTIFY_INVAL_ENTRY;
- nlen = strlen (dentry->name);
- fouh->len = sizeof (*fouh) + sizeof (*fnieo) + nlen + 1;
- fnieo->parent = inode_to_fuse_nodeid (dentry->parent);
+ nlen = strlen(dentry->name);
+ fouh->len = sizeof(*fouh) + sizeof(*fnieo) + nlen + 1;
+ fnieo->parent = inode_to_fuse_nodeid(dentry->parent);
- fnieo->namelen = nlen;
- strcpy (node->inval_buf + sizeof (*fouh) + sizeof (*fnieo),
- dentry->name);
+ fnieo->namelen = nlen;
+ strcpy(node->inval_buf + sizeof(*fouh) + sizeof(*fnieo), dentry->name);
- pthread_mutex_lock (&priv->invalidate_mutex);
- {
- list_add_tail (&node->next, &priv->invalidate_list);
- pthread_cond_signal (&priv->invalidate_cond);
- }
- pthread_mutex_unlock (&priv->invalidate_mutex);
+ pthread_mutex_lock(&priv->invalidate_mutex);
+ {
+ list_add_tail(&node->next, &priv->invalidate_list);
+ pthread_cond_signal(&priv->invalidate_cond);
+ }
+ pthread_mutex_unlock(&priv->invalidate_mutex);
- gf_log ("glusterfs-fuse", GF_LOG_TRACE, "INVALIDATE entry: "
- "%"PRIu64"/%s", fnieo->parent, dentry->name);
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "INVALIDATE entry: "
+ "%" PRIu64 "/%s",
+ fnieo->parent, dentry->name);
- if (dentry->parent) {
- fuse_log_eh (this, "Invalidated entry %s (parent: %s)",
- dentry->name,
- uuid_utoa (dentry->parent->gfid));
- } else {
- fuse_log_eh (this, "Invalidated entry %s(nodeid: %" PRIu64 ")",
- dentry->name, fnieo->parent);
- }
+ if (dentry->parent) {
+ fuse_log_eh(this, "Invalidated entry %s (parent: %s)", dentry->name,
+ uuid_utoa(dentry->parent->gfid));
+ } else {
+ fuse_log_eh(this, "Invalidated entry %s(nodeid: %" PRIu64 ")",
+ dentry->name, fnieo->parent);
}
+ }
- if (inode)
- inode_unref (inode);
+ if (inode)
+ inode_unref(inode);
}
#endif
@@ -381,362 +388,351 @@ static void
fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino)
{
#if FUSE_KERNEL_MINOR_VERSION >= 11
- struct fuse_out_header *fouh = NULL;
- struct fuse_notify_inval_inode_out *fniio = NULL;
- fuse_private_t *priv = NULL;
- fuse_invalidate_node_t *node = NULL;
- inode_t *inode = NULL;
+ struct fuse_out_header *fouh = NULL;
+ struct fuse_notify_inval_inode_out *fniio = NULL;
+ fuse_private_t *priv = NULL;
+ fuse_invalidate_node_t *node = NULL;
+ inode_t *inode = NULL;
- priv = this->private;
+ priv = this->private;
- if (!priv->reverse_fuse_thread_started)
- return;
+ if (!priv->reverse_fuse_thread_started)
+ return;
- node = GF_CALLOC (1, sizeof (*node), gf_fuse_mt_invalidate_node_t);
- if (node == NULL)
- return;
+ node = GF_CALLOC(1, sizeof(*node), gf_fuse_mt_invalidate_node_t);
+ if (node == NULL)
+ return;
- INIT_LIST_HEAD (&node->next);
+ INIT_LIST_HEAD(&node->next);
- fouh = (struct fuse_out_header *) node->inval_buf;
- fniio = (struct fuse_notify_inval_inode_out *) (fouh + 1);
+ fouh = (struct fuse_out_header *)node->inval_buf;
+ fniio = (struct fuse_notify_inval_inode_out *)(fouh + 1);
- fouh->unique = 0;
- fouh->error = FUSE_NOTIFY_INVAL_INODE;
- fouh->len = sizeof(struct fuse_out_header) +
+ fouh->unique = 0;
+ fouh->error = FUSE_NOTIFY_INVAL_INODE;
+ fouh->len = sizeof(struct fuse_out_header) +
sizeof(struct fuse_notify_inval_inode_out);
- /* inval the entire mapping until we learn how to be more granular */
- fniio->ino = fuse_ino;
- fniio->off = 0;
- fniio->len = -1;
+ /* inval the entire mapping until we learn how to be more granular */
+ fniio->ino = fuse_ino;
+ fniio->off = 0;
+ fniio->len = -1;
- inode = fuse_ino_to_inode (fuse_ino, this);
+ inode = fuse_ino_to_inode(fuse_ino, this);
- pthread_mutex_lock (&priv->invalidate_mutex);
- {
- list_add_tail (&node->next, &priv->invalidate_list);
- pthread_cond_signal (&priv->invalidate_cond);
- }
- pthread_mutex_unlock (&priv->invalidate_mutex);
+ pthread_mutex_lock(&priv->invalidate_mutex);
+ {
+ list_add_tail(&node->next, &priv->invalidate_list);
+ pthread_cond_signal(&priv->invalidate_cond);
+ }
+ pthread_mutex_unlock(&priv->invalidate_mutex);
- gf_log ("glusterfs-fuse", GF_LOG_TRACE, "INVALIDATE inode: %" PRIu64,
- fuse_ino);
+ gf_log("glusterfs-fuse", GF_LOG_TRACE, "INVALIDATE inode: %" PRIu64,
+ fuse_ino);
- if (inode) {
- fuse_log_eh (this, "Invalidated inode %" PRIu64 " (gfid: %s)",
- fuse_ino, uuid_utoa (inode->gfid));
- } else {
- fuse_log_eh (this, "Invalidated inode %" PRIu64, fuse_ino);
- }
+ if (inode) {
+ fuse_log_eh(this, "Invalidated inode %" PRIu64 " (gfid: %s)", fuse_ino,
+ uuid_utoa(inode->gfid));
+ } else {
+ fuse_log_eh(this, "Invalidated inode %" PRIu64, fuse_ino);
+ }
- if (inode)
- inode_unref (inode);
+ if (inode)
+ inode_unref(inode);
#else
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "fuse_invalidate_inode not implemented on OS X due to missing FUSE notification");
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "fuse_invalidate_inode not implemented on OS X due to missing FUSE "
+ "notification");
#endif
}
-
int
-send_fuse_err (xlator_t *this, fuse_in_header_t *finh, int error)
+send_fuse_err(xlator_t *this, fuse_in_header_t *finh, int error)
{
- struct fuse_out_header fouh = {0, };
- struct iovec iov_out;
- inode_t *inode = NULL;
+ struct fuse_out_header fouh = {
+ 0,
+ };
+ struct iovec iov_out;
+ inode_t *inode = NULL;
- fouh.error = -error;
- iov_out.iov_base = &fouh;
+ fouh.error = -error;
+ iov_out.iov_base = &fouh;
- inode = fuse_ino_to_inode (finh->nodeid, this);
+ inode = fuse_ino_to_inode(finh->nodeid, this);
- // filter out ENOENT
- if (error != ENOENT) {
- if (inode) {
- fuse_log_eh (this,"Sending %s for operation %d on "
- "inode %s", strerror (error), finh->opcode,
- uuid_utoa (inode->gfid));
- } else {
- fuse_log_eh (this, "Sending %s for operation %d on "
- "inode %" GF_PRI_INODE, strerror (error),
- finh->opcode, finh->nodeid);
- }
+ // filter out ENOENT
+ if (error != ENOENT) {
+ if (inode) {
+ fuse_log_eh(this,
+ "Sending %s for operation %d on "
+ "inode %s",
+ strerror(error), finh->opcode, uuid_utoa(inode->gfid));
+ } else {
+ fuse_log_eh(this,
+ "Sending %s for operation %d on "
+ "inode %" GF_PRI_INODE,
+ strerror(error), finh->opcode, finh->nodeid);
}
+ }
- if (inode)
- inode_unref (inode);
+ if (inode)
+ inode_unref(inode);
- return send_fuse_iov (this, finh, &iov_out, 1);
+ return send_fuse_iov(this, finh, &iov_out, 1);
}
static int
-fuse_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf, dict_t *xdata)
-{
- fuse_state_t *state = NULL;
- fuse_in_header_t *finh = NULL;
- struct fuse_entry_out feo = {0, };
- fuse_private_t *priv = NULL;
- inode_t *linked_inode = NULL;
- uint64_t ctx_value = LOOKUP_NOT_NEEDED;
-
- priv = this->private;
- state = frame->root->state;
- finh = state->finh;
-
- if (op_ret == 0) {
- if (__is_root_gfid (state->loc.inode->gfid))
- buf->ia_ino = 1;
- if (gf_uuid_is_null (buf->ia_gfid)) {
- /* With a NULL gfid inode linking is
- not possible. Let's not pretend this
- call was a "success".
- */
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "Received NULL gfid for %s. Forcing EIO",
- state->loc.path);
- op_ret = -1;
- op_errno = EIO;
- }
- }
-
- /* log into the event-history after the null uuid check is done, since
- * the op_ret and op_errno are being changed if the gfid is NULL.
- */
- fuse_log_eh (this, "op_ret: %d op_errno: %d "
- "%"PRIu64": %s() %s => %s", op_ret, op_errno,
- frame->root->unique, gf_fop_list[frame->root->op],
- state->loc.path, (op_ret == 0)?
- uuid_utoa(buf->ia_gfid):uuid_utoa(state->loc.gfid));
-
- if (op_ret == 0) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": %s() %s => %"PRIu64,
- frame->root->unique, gf_fop_list[frame->root->op],
- state->loc.path, buf->ia_ino);
-
- buf->ia_blksize = this->ctx->page_size;
- gf_fuse_stat2attr (buf, &feo.attr, priv->enable_ino32);
-
- if (!buf->ia_ino) {
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "%"PRIu64": %s() %s returning inode 0",
- frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path);
- }
-
- linked_inode = inode_link (inode, state->loc.parent,
- state->loc.name, buf);
-
- if (linked_inode == inode) {
- inode_ctx_set (linked_inode, this, &ctx_value);
- }
-
- inode_lookup (linked_inode);
-
- feo.nodeid = inode_to_fuse_nodeid (linked_inode);
-
- inode_unref (linked_inode);
-
- feo.entry_valid =
- calc_timeout_sec (priv->entry_timeout);
- feo.entry_valid_nsec =
- calc_timeout_nsec (priv->entry_timeout);
- feo.attr_valid =
- calc_timeout_sec (priv->attribute_timeout);
- feo.attr_valid_nsec =
- calc_timeout_nsec (priv->attribute_timeout);
+fuse_entry_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, dict_t *xdata)
+{
+ fuse_state_t *state = NULL;
+ fuse_in_header_t *finh = NULL;
+ struct fuse_entry_out feo = {
+ 0,
+ };
+ fuse_private_t *priv = NULL;
+ inode_t *linked_inode = NULL;
+ uint64_t ctx_value = LOOKUP_NOT_NEEDED;
+
+ priv = this->private;
+ state = frame->root->state;
+ finh = state->finh;
+
+ if (op_ret == 0) {
+ if (__is_root_gfid(state->loc.inode->gfid))
+ buf->ia_ino = 1;
+ if (gf_uuid_is_null(buf->ia_gfid)) {
+ /* With a NULL gfid inode linking is
+ not possible. Let's not pretend this
+ call was a "success".
+ */
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "Received NULL gfid for %s. Forcing EIO", state->loc.path);
+ op_ret = -1;
+ op_errno = EIO;
+ }
+ }
+
+ /* log into the event-history after the null uuid check is done, since
+ * the op_ret and op_errno are being changed if the gfid is NULL.
+ */
+ fuse_log_eh(
+ this,
+ "op_ret: %d op_errno: %d "
+ "%" PRIu64 ": %s() %s => %s",
+ op_ret, op_errno, frame->root->unique, gf_fop_list[frame->root->op],
+ state->loc.path,
+ (op_ret == 0) ? uuid_utoa(buf->ia_gfid) : uuid_utoa(state->loc.gfid));
+
+ if (op_ret == 0) {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": %s() %s => %" PRIu64, frame->root->unique,
+ gf_fop_list[frame->root->op], state->loc.path, buf->ia_ino);
+
+ buf->ia_blksize = this->ctx->page_size;
+ gf_fuse_stat2attr(buf, &feo.attr, priv->enable_ino32);
+
+ if (!buf->ia_ino) {
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64 ": %s() %s returning inode 0",
+ frame->root->unique, gf_fop_list[frame->root->op],
+ state->loc.path);
+ }
+
+ linked_inode = inode_link(inode, state->loc.parent, state->loc.name,
+ buf);
+
+ if (linked_inode == inode) {
+ inode_ctx_set(linked_inode, this, &ctx_value);
+ }
+
+ inode_lookup(linked_inode);
+
+ feo.nodeid = inode_to_fuse_nodeid(linked_inode);
+
+ inode_unref(linked_inode);
+
+ feo.entry_valid = calc_timeout_sec(priv->entry_timeout);
+ feo.entry_valid_nsec = calc_timeout_nsec(priv->entry_timeout);
+ feo.attr_valid = calc_timeout_sec(priv->attribute_timeout);
+ feo.attr_valid_nsec = calc_timeout_nsec(priv->attribute_timeout);
#if FUSE_KERNEL_MINOR_VERSION >= 9
- priv->proto_minor >= 9 ?
- send_fuse_obj (this, finh, &feo) :
- send_fuse_data (this, finh, &feo,
- FUSE_COMPAT_ENTRY_OUT_SIZE);
+ priv->proto_minor >= 9
+ ? send_fuse_obj(this, finh, &feo)
+ : send_fuse_data(this, finh, &feo, FUSE_COMPAT_ENTRY_OUT_SIZE);
#else
- send_fuse_obj (this, finh, &feo);
+ send_fuse_obj(this, finh, &feo);
#endif
+ } else {
+ gf_log("glusterfs-fuse",
+ (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_WARNING),
+ "%" PRIu64 ": %s() %s => -1 (%s)", frame->root->unique,
+ gf_fop_list[frame->root->op], state->loc.path,
+ strerror(op_errno));
+
+ if ((op_errno == ENOENT) && (priv->negative_timeout != 0)) {
+ feo.entry_valid = calc_timeout_sec(priv->negative_timeout);
+ feo.entry_valid_nsec = calc_timeout_nsec(priv->negative_timeout);
+ send_fuse_obj(this, finh, &feo);
} else {
- gf_log ("glusterfs-fuse",
- (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_WARNING),
- "%"PRIu64": %s() %s => -1 (%s)", frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path,
- strerror (op_errno));
-
- if ((op_errno == ENOENT) && (priv->negative_timeout != 0)) {
- feo.entry_valid =
- calc_timeout_sec (priv->negative_timeout);
- feo.entry_valid_nsec =
- calc_timeout_nsec (priv->negative_timeout);
- send_fuse_obj (this, finh, &feo);
- } else {
- send_fuse_err (this, state->finh, op_errno);
- }
+ send_fuse_err(this, state->finh, op_errno);
}
+ }
- free_fuse_state (state);
- STACK_DESTROY (frame->root);
- return 0;
+ free_fuse_state(state);
+ STACK_DESTROY(frame->root);
+ return 0;
}
static int
-fuse_newentry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+fuse_newentry_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- fuse_entry_cbk (frame, cookie, this, op_ret, op_errno, inode, buf,
- xdata);
- return 0;
+ fuse_entry_cbk(frame, cookie, this, op_ret, op_errno, inode, buf, xdata);
+ return 0;
}
static int
-fuse_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *stat, dict_t *dict,
- struct iatt *postparent)
-{
- fuse_state_t *state = NULL;
- call_frame_t *prev = NULL;
- inode_table_t *itable = NULL;
-
- state = frame->root->state;
- prev = cookie;
-
- if (op_ret == -1 && state->is_revalidate == 1) {
- itable = state->itable;
- /*
- * A stale mapping might exist for a dentry/inode that has been
- * removed from another client.
- */
- if (op_errno == ENOENT)
- inode_unlink(state->loc.inode, state->loc.parent,
- state->loc.name);
- inode_unref (state->loc.inode);
- state->loc.inode = inode_new (itable);
- state->is_revalidate = 2;
- if (gf_uuid_is_null (state->gfid))
- gf_uuid_generate (state->gfid);
- fuse_gfid_set (state);
-
- STACK_WIND (frame, fuse_lookup_cbk,
- prev->this, prev->this->fops->lookup,
- &state->loc, state->xdata);
- return 0;
- }
+fuse_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stat, dict_t *dict, struct iatt *postparent)
+{
+ fuse_state_t *state = NULL;
+ call_frame_t *prev = NULL;
+ inode_table_t *itable = NULL;
+
+ state = frame->root->state;
+ prev = cookie;
- fuse_entry_cbk (frame, cookie, this, op_ret, op_errno, inode, stat,
- dict);
+ if (op_ret == -1 && state->is_revalidate == 1) {
+ itable = state->itable;
+ /*
+ * A stale mapping might exist for a dentry/inode that has been
+ * removed from another client.
+ */
+ if (op_errno == ENOENT)
+ inode_unlink(state->loc.inode, state->loc.parent, state->loc.name);
+ inode_unref(state->loc.inode);
+ state->loc.inode = inode_new(itable);
+ state->is_revalidate = 2;
+ if (gf_uuid_is_null(state->gfid))
+ gf_uuid_generate(state->gfid);
+ fuse_gfid_set(state);
+
+ STACK_WIND(frame, fuse_lookup_cbk, prev->this, prev->this->fops->lookup,
+ &state->loc, state->xdata);
return 0;
+ }
+
+ fuse_entry_cbk(frame, cookie, this, op_ret, op_errno, inode, stat, dict);
+ return 0;
}
void
-fuse_fop_resume (fuse_state_t *state)
+fuse_fop_resume(fuse_state_t *state)
{
- fuse_resume_fn_t fn = NULL;
+ fuse_resume_fn_t fn = NULL;
- /*
- * Fail fd resolution failures right away.
- */
- if (state->resolve.fd && state->resolve.op_ret < 0) {
- send_fuse_err (state->this, state->finh,
- state->resolve.op_errno);
- free_fuse_state (state);
- return;
- }
+ /*
+ * Fail fd resolution failures right away.
+ */
+ if (state->resolve.fd && state->resolve.op_ret < 0) {
+ send_fuse_err(state->this, state->finh, state->resolve.op_errno);
+ free_fuse_state(state);
+ return;
+ }
- fn = state->resume_fn;
- fn (state);
+ fn = state->resume_fn;
+ fn(state);
}
void
-fuse_lookup_resume (fuse_state_t *state)
-{
- if (!state->loc.parent && !state->loc.inode) {
- gf_log ("fuse", GF_LOG_ERROR, "failed to resolve path %s",
- state->loc.path);
- send_fuse_err (state->this, state->finh,
- state->resolve.op_errno);
- free_fuse_state (state);
- return;
- }
-
- /* parent was resolved, entry could not, may be a missing gfid?
- * Hence try to do a regular lookup
- */
- if ((state->resolve.op_ret == -1)
- && (state->resolve.op_errno == ENODATA)) {
- state->resolve.op_ret = 0;
- }
-
- if (state->loc.inode) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": LOOKUP %s(%s)", state->finh->unique,
- state->loc.path, uuid_utoa (state->loc.inode->gfid));
- state->is_revalidate = 1;
- } else {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": LOOKUP %s", state->finh->unique,
- state->loc.path);
- state->loc.inode = inode_new (state->loc.parent->table);
- if (gf_uuid_is_null (state->gfid))
- gf_uuid_generate (state->gfid);
- fuse_gfid_set (state);
- }
+fuse_lookup_resume(fuse_state_t *state)
+{
+ if (!state->loc.parent && !state->loc.inode) {
+ gf_log("fuse", GF_LOG_ERROR, "failed to resolve path %s",
+ state->loc.path);
+ send_fuse_err(state->this, state->finh, state->resolve.op_errno);
+ free_fuse_state(state);
+ return;
+ }
- FUSE_FOP (state, fuse_lookup_cbk, GF_FOP_LOOKUP,
- lookup, &state->loc, state->xdata);
+ /* parent was resolved, entry could not, may be a missing gfid?
+ * Hence try to do a regular lookup
+ */
+ if ((state->resolve.op_ret == -1) && (state->resolve.op_errno == ENODATA)) {
+ state->resolve.op_ret = 0;
+ }
+
+ if (state->loc.inode) {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE, "%" PRIu64 ": LOOKUP %s(%s)",
+ state->finh->unique, state->loc.path,
+ uuid_utoa(state->loc.inode->gfid));
+ state->is_revalidate = 1;
+ } else {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE, "%" PRIu64 ": LOOKUP %s",
+ state->finh->unique, state->loc.path);
+ state->loc.inode = inode_new(state->loc.parent->table);
+ if (gf_uuid_is_null(state->gfid))
+ gf_uuid_generate(state->gfid);
+ fuse_gfid_set(state);
+ }
+
+ FUSE_FOP(state, fuse_lookup_cbk, GF_FOP_LOOKUP, lookup, &state->loc,
+ state->xdata);
}
static void
-fuse_lookup (xlator_t *this, fuse_in_header_t *finh, void *msg,
- struct iobuf *iobuf)
+fuse_lookup(xlator_t *this, fuse_in_header_t *finh, void *msg,
+ struct iobuf *iobuf)
{
- char *name = msg;
- fuse_state_t *state = NULL;
+ char *name = msg;
+ fuse_state_t *state = NULL;
- GET_STATE (this, finh, state);
+ GET_STATE(this, finh, state);
- (void) fuse_resolve_entry_init (state, &state->resolve,
- finh->nodeid, name);
+ (void)fuse_resolve_entry_init(state, &state->resolve, finh->nodeid, name);
- fuse_resolve_and_resume (state, fuse_lookup_resume);
+ fuse_resolve_and_resume(state, fuse_lookup_resume);
- return;
+ return;
}
static void
do_forget(xlator_t *this, uint64_t unique, uint64_t nodeid, uint64_t nlookup)
{
- inode_t *fuse_inode = fuse_ino_to_inode(nodeid, this);
+ inode_t *fuse_inode = fuse_ino_to_inode(nodeid, this);
- fuse_log_eh(this, "%"PRIu64": FORGET %"PRIu64"/%"PRIu64" gfid: (%s)",
- unique, nodeid, nlookup, uuid_utoa(fuse_inode->gfid));
+ fuse_log_eh(this, "%" PRIu64 ": FORGET %" PRIu64 "/%" PRIu64 " gfid: (%s)",
+ unique, nodeid, nlookup, uuid_utoa(fuse_inode->gfid));
- inode_forget(fuse_inode, nlookup);
- inode_unref(fuse_inode);
+ inode_forget(fuse_inode, nlookup);
+ inode_unref(fuse_inode);
}
static void
-fuse_forget (xlator_t *this, fuse_in_header_t *finh, void *msg,
- struct iobuf *iobuf)
+fuse_forget(xlator_t *this, fuse_in_header_t *finh, void *msg,
+ struct iobuf *iobuf)
{
- struct fuse_forget_in *ffi = msg;
+ struct fuse_forget_in *ffi = msg;
- if (finh->nodeid == 1) {
- GF_FREE (finh);
- return;
- }
+ if (finh->nodeid == 1) {
+ GF_FREE(finh);
+ return;
+ }
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": FORGET %"PRIu64"/%"PRIu64,
- finh->unique, finh->nodeid, ffi->nlookup);
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": FORGET %" PRIu64 "/%" PRIu64, finh->unique,
+ finh->nodeid, ffi->nlookup);
- do_forget(this, finh->unique, finh->nodeid, ffi->nlookup);
+ do_forget(this, finh->unique, finh->nodeid, ffi->nlookup);
- GF_FREE (finh);
+ GF_FREE(finh);
}
#if FUSE_KERNEL_MINOR_VERSION >= 16
@@ -744,2398 +740,2350 @@ static void
fuse_batch_forget(xlator_t *this, fuse_in_header_t *finh, void *msg,
struct iobuf *iobuf)
{
- struct fuse_batch_forget_in *fbfi = msg;
- struct fuse_forget_one *ffo = (struct fuse_forget_one *) (fbfi + 1);
- int i;
+ struct fuse_batch_forget_in *fbfi = msg;
+ struct fuse_forget_one *ffo = (struct fuse_forget_one *)(fbfi + 1);
+ int i;
- gf_log("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": BATCH_FORGET %"PRIu64"/%"PRIu32,
- finh->unique, finh->nodeid, fbfi->count);
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": BATCH_FORGET %" PRIu64 "/%" PRIu32, finh->unique,
+ finh->nodeid, fbfi->count);
- for (i = 0; i < fbfi->count; i++) {
- if (ffo[i].nodeid == 1)
- continue;
- do_forget(this, finh->unique, ffo[i].nodeid, ffo[i].nlookup);
- }
- GF_FREE(finh);
+ for (i = 0; i < fbfi->count; i++) {
+ if (ffo[i].nodeid == 1)
+ continue;
+ do_forget(this, finh->unique, ffo[i].nodeid, ffo[i].nlookup);
+ }
+ GF_FREE(finh);
}
#endif
static int
-fuse_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+fuse_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- fuse_state_t *state;
- fuse_in_header_t *finh;
- fuse_private_t *priv = NULL;
- struct fuse_attr_out fao;
+ fuse_state_t *state;
+ fuse_in_header_t *finh;
+ fuse_private_t *priv = NULL;
+ struct fuse_attr_out fao;
- priv = this->private;
- state = frame->root->state;
- finh = state->finh;
+ priv = this->private;
+ state = frame->root->state;
+ finh = state->finh;
- fuse_log_eh_fop(this, state, frame, op_ret, op_errno);
+ fuse_log_eh_fop(this, state, frame, op_ret, op_errno);
- if (op_ret == 0) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": %s() %s => %"PRIu64, frame->root->unique,
- gf_fop_list[frame->root->op],
- state->loc.path ? state->loc.path : "ERR",
- prebuf->ia_ino);
+ if (op_ret == 0) {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": %s() %s => %" PRIu64, frame->root->unique,
+ gf_fop_list[frame->root->op],
+ state->loc.path ? state->loc.path : "ERR", prebuf->ia_ino);
- postbuf->ia_blksize = this->ctx->page_size;
- gf_fuse_stat2attr (postbuf, &fao.attr, priv->enable_ino32);
+ postbuf->ia_blksize = this->ctx->page_size;
+ gf_fuse_stat2attr(postbuf, &fao.attr, priv->enable_ino32);
- fao.attr_valid = calc_timeout_sec (priv->attribute_timeout);
- fao.attr_valid_nsec =
- calc_timeout_nsec (priv->attribute_timeout);
+ fao.attr_valid = calc_timeout_sec(priv->attribute_timeout);
+ fao.attr_valid_nsec = calc_timeout_nsec(priv->attribute_timeout);
#if FUSE_KERNEL_MINOR_VERSION >= 9
- priv->proto_minor >= 9 ?
- send_fuse_obj (this, finh, &fao) :
- send_fuse_data (this, finh, &fao,
- FUSE_COMPAT_ATTR_OUT_SIZE);
+ priv->proto_minor >= 9
+ ? send_fuse_obj(this, finh, &fao)
+ : send_fuse_data(this, finh, &fao, FUSE_COMPAT_ATTR_OUT_SIZE);
#else
- send_fuse_obj (this, finh, &fao);
+ send_fuse_obj(this, finh, &fao);
#endif
- } else {
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "%"PRIu64": %s() %s => -1 (%s)", frame->root->unique,
- gf_fop_list[frame->root->op],
- state->loc.path ? state->loc.path : "ERR",
- strerror (op_errno));
+ } else {
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64 ": %s() %s => -1 (%s)", frame->root->unique,
+ gf_fop_list[frame->root->op],
+ state->loc.path ? state->loc.path : "ERR", strerror(op_errno));
- send_fuse_err (this, finh, op_errno);
- }
+ send_fuse_err(this, finh, op_errno);
+ }
- free_fuse_state (state);
- STACK_DESTROY (frame->root);
+ free_fuse_state(state);
+ STACK_DESTROY(frame->root);
- return 0;
+ return 0;
}
static int
-fuse_root_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *stat, dict_t *dict,
- struct iatt *postparent);
+fuse_root_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stat, dict_t *dict, struct iatt *postparent);
static int
-fuse_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
-{
- int32_t ret = 0;
- fuse_state_t *state;
- fuse_in_header_t *finh;
- fuse_private_t *priv = NULL;
- struct fuse_attr_out fao;
-
- priv = this->private;
- state = frame->root->state;
- finh = state->finh;
-
- fuse_log_eh (this, "op_ret: %d, op_errno: %d, %"PRIu64": %s() %s => "
- "gfid: %s", op_ret, op_errno, frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path,
- state->loc.inode ? uuid_utoa (state->loc.inode->gfid) : "");
- if (op_ret == 0) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": %s() %s => %"PRIu64, frame->root->unique,
- gf_fop_list[frame->root->op],
- state->loc.path ? state->loc.path : "ERR",
- buf->ia_ino);
-
- buf->ia_blksize = this->ctx->page_size;
- gf_fuse_stat2attr (buf, &fao.attr, priv->enable_ino32);
-
- fao.attr_valid = calc_timeout_sec (priv->attribute_timeout);
- fao.attr_valid_nsec =
- calc_timeout_nsec (priv->attribute_timeout);
+fuse_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
+{
+ int32_t ret = 0;
+ fuse_state_t *state;
+ fuse_in_header_t *finh;
+ fuse_private_t *priv = NULL;
+ struct fuse_attr_out fao;
+
+ priv = this->private;
+ state = frame->root->state;
+ finh = state->finh;
+
+ fuse_log_eh(this,
+ "op_ret: %d, op_errno: %d, %" PRIu64
+ ": %s() %s => "
+ "gfid: %s",
+ op_ret, op_errno, frame->root->unique,
+ gf_fop_list[frame->root->op], state->loc.path,
+ state->loc.inode ? uuid_utoa(state->loc.inode->gfid) : "");
+ if (op_ret == 0) {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": %s() %s => %" PRIu64, frame->root->unique,
+ gf_fop_list[frame->root->op],
+ state->loc.path ? state->loc.path : "ERR", buf->ia_ino);
+
+ buf->ia_blksize = this->ctx->page_size;
+ gf_fuse_stat2attr(buf, &fao.attr, priv->enable_ino32);
+
+ fao.attr_valid = calc_timeout_sec(priv->attribute_timeout);
+ fao.attr_valid_nsec = calc_timeout_nsec(priv->attribute_timeout);
#if FUSE_KERNEL_MINOR_VERSION >= 9
- priv->proto_minor >= 9 ?
- send_fuse_obj (this, finh, &fao) :
- send_fuse_data (this, finh, &fao,
- FUSE_COMPAT_ATTR_OUT_SIZE);
+ priv->proto_minor >= 9
+ ? send_fuse_obj(this, finh, &fao)
+ : send_fuse_data(this, finh, &fao, FUSE_COMPAT_ATTR_OUT_SIZE);
#else
- send_fuse_obj (this, finh, &fao);
+ send_fuse_obj(this, finh, &fao);
#endif
- } else {
- /* This is moved here from fuse_getattr(). It makes sense as
- in few cases, like the self-heal processes, some
- translators expect a lookup() to come on root inode
- (inode number 1). This will make sure we don't fail in any
- case, but the positive path will get better performance,
- by following common path for all the cases */
- if ((finh->nodeid == 1) && (state->gfid[15] != 1)) {
- /* The 'state->gfid[15]' check is added to prevent the
- infinite recursions */
- state->gfid[15] = 1;
-
- ret = fuse_loc_fill (&state->loc, state, finh->nodeid,
- 0, NULL);
- if (ret < 0) {
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "%"PRIu64": loc_fill() on / failed",
- finh->unique);
- send_fuse_err (this, finh, ENOENT);
- free_fuse_state (state);
- return 0;
- }
-
- fuse_gfid_set (state);
-
- FUSE_FOP (state, fuse_root_lookup_cbk, GF_FOP_LOOKUP,
- lookup, &state->loc, state->xdata);
-
- return 0;
- }
+ } else {
+ /* This is moved here from fuse_getattr(). It makes sense as
+ in few cases, like the self-heal processes, some
+ translators expect a lookup() to come on root inode
+ (inode number 1). This will make sure we don't fail in any
+ case, but the positive path will get better performance,
+ by following common path for all the cases */
+ if ((finh->nodeid == 1) && (state->gfid[15] != 1)) {
+ /* The 'state->gfid[15]' check is added to prevent the
+ infinite recursions */
+ state->gfid[15] = 1;
+
+ ret = fuse_loc_fill(&state->loc, state, finh->nodeid, 0, NULL);
+ if (ret < 0) {
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64 ": loc_fill() on / failed", finh->unique);
+ send_fuse_err(this, finh, ENOENT);
+ free_fuse_state(state);
+ return 0;
+ }
- gf_log ("glusterfs-fuse", GF_LOG_WARNING, "%"PRIu64": %s() "
- "%s => -1 (%s)", frame->root->unique,
- gf_fop_list[frame->root->op],
- state->loc.path ? state->loc.path : "ERR",
- strerror (op_errno));
+ fuse_gfid_set(state);
- send_fuse_err (this, finh, op_errno);
+ FUSE_FOP(state, fuse_root_lookup_cbk, GF_FOP_LOOKUP, lookup,
+ &state->loc, state->xdata);
+
+ return 0;
}
- free_fuse_state (state);
- STACK_DESTROY (frame->root);
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64
+ ": %s() "
+ "%s => -1 (%s)",
+ frame->root->unique, gf_fop_list[frame->root->op],
+ state->loc.path ? state->loc.path : "ERR", strerror(op_errno));
- return 0;
+ send_fuse_err(this, finh, op_errno);
+ }
+
+ free_fuse_state(state);
+ STACK_DESTROY(frame->root);
+
+ return 0;
}
static int
-fuse_root_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *stat, dict_t *dict,
- struct iatt *postparent)
+fuse_root_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stat, dict_t *dict, struct iatt *postparent)
{
- fuse_attr_cbk (frame, cookie, this, op_ret, op_errno, stat, dict);
+ fuse_attr_cbk(frame, cookie, this, op_ret, op_errno, stat, dict);
- return 0;
+ return 0;
}
void
-fuse_getattr_resume (fuse_state_t *state)
-{
- if (!state->loc.inode && !(state->fd && state->fd->inode)) {
- gf_log ("glusterfs-fuse", GF_LOG_ERROR,
- "%"PRIu64": GETATTR %"PRIu64" (%s) resolution failed",
- state->finh->unique, state->finh->nodeid,
- uuid_utoa (state->resolve.gfid));
- send_fuse_err (state->this, state->finh,
- state->resolve.op_errno);
- free_fuse_state (state);
- return;
- }
+fuse_getattr_resume(fuse_state_t *state)
+{
+ if (!state->loc.inode && !(state->fd && state->fd->inode)) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "%" PRIu64 ": GETATTR %" PRIu64 " (%s) resolution failed",
+ state->finh->unique, state->finh->nodeid,
+ uuid_utoa(state->resolve.gfid));
+ send_fuse_err(state->this, state->finh, state->resolve.op_errno);
+ free_fuse_state(state);
+ return;
+ }
- if (state->fd == NULL && !IA_ISDIR (state->loc.inode->ia_type)) {
- state->fd = fd_lookup (state->loc.inode, state->finh->pid);
+ if (state->fd == NULL && !IA_ISDIR(state->loc.inode->ia_type)) {
+ state->fd = fd_lookup(state->loc.inode, state->finh->pid);
- if (state->fd == NULL)
- state->fd = fd_lookup (state->loc.inode, 0);
- }
+ if (state->fd == NULL)
+ state->fd = fd_lookup(state->loc.inode, 0);
+ }
- if (!state->fd) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": GETATTR %"PRIu64" (%s)",
- state->finh->unique, state->finh->nodeid,
- state->loc.path);
+ if (!state->fd) {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": GETATTR %" PRIu64 " (%s)", state->finh->unique,
+ state->finh->nodeid, state->loc.path);
- FUSE_FOP (state, fuse_attr_cbk, GF_FOP_STAT,
- stat, &state->loc, state->xdata);
- } else {
+ FUSE_FOP(state, fuse_attr_cbk, GF_FOP_STAT, stat, &state->loc,
+ state->xdata);
+ } else {
+ gf_log("glusterfs-fuse", GF_LOG_TRACE,
+ "%" PRIu64 ": FGETATTR %" PRIu64 " (%s/%p)", state->finh->unique,
+ state->finh->nodeid, state->loc.path, state->fd);
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": FGETATTR %"PRIu64" (%s/%p)",
- state->finh->unique, state->finh->nodeid,
- state->loc.path, state->fd);
-
- FUSE_FOP (state, fuse_attr_cbk, GF_FOP_FSTAT,
- fstat, state->fd, state->xdata);
- }
+ FUSE_FOP(state, fuse_attr_cbk, GF_FOP_FSTAT, fstat, state->fd,
+ state->xdata);
+ }
}
static void
-fuse_getattr (xlator_t *this, fuse_in_header_t *finh, void *msg,
- struct iobuf *iobuf)
+fuse_getattr(xlator_t *this, fuse_in_header_t *finh, void *msg,
+ struct iobuf *iobuf)
{
#if FUSE_KERNEL_MINOR_VERSION >= 9
- struct fuse_getattr_in *fgi = msg;
- fuse_private_t *priv = NULL;
+ struct fuse_getattr_in *fgi = msg;
+ fuse_private_t *priv = NULL;
#endif
- fuse_state_t *state;
- int ret = -1;
+ fuse_state_t *state;
+ int ret = -1;
- GET_STATE (this, finh, state);
+ GET_STATE(this, finh, state);
#if FUSE_KERNEL_MINOR_VERSION >= 9
- priv = this->private;
- if (priv->proto_minor >= 9 && fgi->getattr_flags & FUSE_GETATTR_FH)
- state->fd = fd_ref ((fd_t *)fgi->fh);
+ priv = this->private;
+ if (priv->proto_minor >= 9 && fgi->getattr_flags & FUSE_GETATTR_FH)
+ state->fd = fd_ref((fd_t *)fgi->fh);
#endif
- if (finh->nodeid == 1) {
- state->gfid[15] = 1;
-
- ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL);
- if (ret < 0) {
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "%"PRIu64": GETATTR on / (fuse_loc_fill() failed)",
- finh->unique);
- send_fuse_err (this, finh, ENOENT);
- free_fuse_state (state);
- return;
- }
-
- fuse_gfid_set (state);
+ if (finh->nodeid == 1) {
+ state->gfid[15] = 1;
- FUSE_FOP (state, fuse_root_lookup_cbk, GF_FOP_LOOKUP,
- lookup, &state->loc, state->xdata);
- return;
+ ret = fuse_loc_fill(&state->loc, state, finh->nodeid, 0, NULL);
+ if (ret < 0) {
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64 ": GETATTR on / (fuse_loc_fill() failed)",
+ finh->unique);
+ send_fuse_err(this, finh, ENOENT);
+ free_fuse_state(state);
+ return;
}
- if (state->fd)
- fuse_resolve_fd_init (state, &state->resolve, state->fd);
- else
- fuse_resolve_inode_init (state, &state->resolve, state->finh->nodeid);
+ fuse_gfid_set(state);
- fuse_resolve_and_resume (state, fuse_getattr_resume);
+ FUSE_FOP(state, fuse_root_lookup_cbk, GF_FOP_LOOKUP, lookup,
+ &state->loc, state->xdata);
+ return;
+ }
+
+ if (state->fd)
+ fuse_resolve_fd_init(state, &state->resolve, state->fd);
+ else
+ fuse_resolve_inode_init(state, &state->resolve, state->finh->nodeid);
+
+ fuse_resolve_and_resume(state, fuse_getattr_resume);
}
static int32_t
-fuse_fd_inherit_directio (xlator_t *this, fd_t *fd, struct fuse_open_out *foo)
-{
- int32_t ret = 0;
- fuse_fd_ctx_t *fdctx = NULL, *tmp_fdctx = NULL;
- fd_t *tmp_fd = NULL;
-
- GF_VALIDATE_OR_GOTO_WITH_ERROR ("glusterfs-fuse", this, out, ret,
- -EINVAL);
- GF_VALIDATE_OR_GOTO_WITH_ERROR ("glusterfs-fuse", fd, out, ret,
- -EINVAL);
- GF_VALIDATE_OR_GOTO_WITH_ERROR ("glusterfs-fuse", foo, out, ret,
- -EINVAL);
-
- fdctx = fuse_fd_ctx_get (this, fd);
- if (!fdctx) {
- ret = -ENOMEM;
- goto out;
- }
+fuse_fd_inherit_directio(xlator_t *this, fd_t *fd, struct fuse_open_out *foo)
+{
+ int32_t ret = 0;
+ fuse_fd_ctx_t *fdctx = NULL, *tmp_fdctx = NULL;
+ fd_t *tmp_fd = NULL;
- tmp_fd = fd_lookup (fd->inode, 0);
- if (tmp_fd) {
- tmp_fdctx = fuse_fd_ctx_get (this, tmp_fd);
- if (tmp_fdctx) {
- foo->open_flags &= ~FOPEN_DIRECT_IO;
- foo->open_flags |= (tmp_fdctx->open_flags
- & FOPEN_DIRECT_IO);
- }
- }
+ GF_VALIDATE_OR_GOTO_WITH_ERROR("glusterfs-fuse", this, out, ret, -EINVAL);
+ GF_VALIDATE_OR_GOTO_WITH_ERROR("glusterfs-fuse", fd, out, ret, -EINVAL);
+ GF_VALIDATE_OR_GOTO_WITH_ERROR("glusterfs-fuse", foo, out, ret, -EINVAL);
- fdctx->open_flags |= (foo->open_flags & FOPEN_DIRECT_IO);
+ fdctx = fuse_fd_ctx_get(this, fd);
+ if (!fdctx) {
+ ret = -ENOMEM;
+ goto out;
+ }
- if (tmp_fd != NULL) {
- fd_unref (tmp_fd);
+ tmp_fd = fd_lookup(fd->inode, 0);
+ if (tmp_fd) {
+ tmp_fdctx = fuse_fd_ctx_get(this, tmp_fd);
+ if (tmp_fdctx) {
+ foo->open_flags &= ~FOPEN_DIRECT_IO;
+ foo->open_flags |= (tmp_fdctx->open_flags & FOPEN_DIRECT_IO);
}
+ }
- ret = 0;
+ fdctx->open_flags |= (foo->open_flags & FOPEN_DIRECT_IO);
+
+ if (tmp_fd != NULL) {
+ fd_unref(tmp_fd);
+ }
+
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
gf_boolean_t
-direct_io_mode (dict_t *xdata)
+direct_io_mode(dict_t *xdata)
{
- if (xdata && dict_get (xdata, "direct-io-mode"))
- return _gf_true;
- return _gf_false;
+ if (xdata && dict_get(xdata, "direct-io-mode"))
+ return _gf_true;
+ return _gf_false;
}
-
static int
-fuse_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
-{
- fuse_state_t *state = NULL;
- fuse_in_header_t *finh = NULL;
- fuse_private_t *priv = NULL;
- int32_t ret = 0;
- struct fuse_open_out foo = {0, };
-
- priv = this->private;
- state = frame->root->state;
- finh = state->finh;
-
- fuse_log_eh_fop(this, state, frame, op_ret, op_errno);
-
- if (op_ret >= 0) {
- foo.fh = (uintptr_t) fd;
- foo.open_flags = 0;
-
- if (!IA_ISDIR (fd->inode->ia_type)) {
- if (((priv->direct_io_mode == 2)
- && ((state->flags & O_ACCMODE) != O_RDONLY))
- || (priv->direct_io_mode == 1)
- || (direct_io_mode (xdata)))
- foo.open_flags |= FOPEN_DIRECT_IO;
+fuse_fd_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd, dict_t *xdata)
+{
+ fuse_state_t *state = NULL;
+ fuse_in_header_t *finh = NULL;
+ fuse_private_t *priv = NULL;
+ int32_t ret = 0;
+ struct fuse_open_out foo = {
+ 0,
+ };
+
+ priv = this->private;
+ state = frame->root->state;
+ finh = state->finh;
+
+ fuse_log_eh_fop(this, state, frame, op_ret, op_errno);
+
+ if (op_ret >= 0) {
+ foo.fh = (uintptr_t)fd;
+ foo.open_flags = 0;
+
+ if (!IA_ISDIR(fd->inode->ia_type)) {
+ if (((priv->direct_io_mode == 2) &&
+ ((state->flags & O_ACCMODE) != O_RDONLY)) ||
+ (priv->direct_io_mode == 1) || (direct_io_mode(xdata)))
+ foo.open_flags |= FOPEN_DIRECT_IO;
#ifdef GF_DARWIN_HOST_OS
- /* In Linux: by default, buffer cache
- * is purged upon open, setting
- * FOPEN_KEEP_CACHE implies no-purge
- *
- * In MacFUSE: by default, buffer cache
- * is left intact upon open, setting
- * FOPEN_PURGE_UBC implies purge
- *
- * [[Interesting...]]
- */
- if (!priv->fopen_keep_cache)
- foo.open_flags |= FOPEN_PURGE_UBC;
+ /* In Linux: by default, buffer cache
+ * is purged upon open, setting
+ * FOPEN_KEEP_CACHE implies no-purge
+ *
+ * In MacFUSE: by default, buffer cache
+ * is left intact upon open, setting
+ * FOPEN_PURGE_UBC implies purge
+ *
+ * [[Interesting...]]
+ */
+ if (!priv->fopen_keep_cache)
+ foo.open_flags |= FOPEN_PURGE_UBC;
#else
- /*
- * If fopen-keep-cache is enabled, we set the associated
- * flag here such that files are not invalidated on open.
- * File invalidations occur either in fuse or explicitly
- * when the cache is set invalid on the inode.
- */
- if (priv->fopen_keep_cache)
- foo.open_flags |= FOPEN_KEEP_CACHE;
+ /*
+ * If fopen-keep-cache is enabled, we set the associated
+ * flag here such that files are not invalidated on open.
+ * File invalidations occur either in fuse or explicitly
+ * when the cache is set invalid on the inode.
+ */
+ if (priv->fopen_keep_cache)
+ foo.open_flags |= FOPEN_KEEP_CACHE;
#endif
- }
+ }
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": %s() %s => %p", frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path, fd);
-
- ret = fuse_fd_inherit_directio (this, fd, &foo);
- if (ret < 0) {
- op_errno = -ret;
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "cannot inherit direct-io values for fd "
- "(ptr:%p inode-gfid:%s) from fds already "
- "opened", fd, uuid_utoa (fd->inode->gfid));
- goto err;
- }
+ gf_log("glusterfs-fuse", GF_LOG_TRACE, "%" PRIu64 ": %s() %s => %p",
+ frame->root->unique, gf_fop_list[frame->root->op],
+ state->loc.path, fd);
- if (send_fuse_obj (this, finh, &foo) == ENOENT) {
- gf_log ("glusterfs-fuse", GF_LOG_DEBUG,
- "open(%s) got EINTR", state->loc.path);
- gf_fd_put (priv->fdtable, state->fd_no);
- goto out;
- }
+ ret = fuse_fd_inherit_directio(this, fd, &foo);
+ if (ret < 0) {
+ op_errno = -ret;
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "cannot inherit direct-io values for fd "
+ "(ptr:%p inode-gfid:%s) from fds already "
+ "opened",
+ fd, uuid_utoa(fd->inode->gfid));
+ goto err;
+ }
+
+ if (send_fuse_obj(this, finh, &foo) == ENOENT) {
+ gf_log("glusterfs-fuse", GF_LOG_DEBUG, "open(%s) got EINTR",
+ state->loc.path);
+ gf_fd_put(priv->fdtable, state->fd_no);
+ goto out;
+ }
+
+ fd_bind(fd);
+ } else {
+ err:
+ /* OPEN(DIR) being an operation on inode should never fail with
+ * ENOENT. If gfid is not present, the appropriate error is
+ * ESTALE.
+ */
+ if (op_errno == ENOENT)
+ op_errno = ESTALE;
- fd_bind (fd);
- } else {
- err:
- /* OPEN(DIR) being an operation on inode should never fail with
- * ENOENT. If gfid is not present, the appropriate error is
- * ESTALE.
- */
- if (op_errno == ENOENT)
- op_errno = ESTALE;
-
- gf_log ("glusterfs-fuse", GF_LOG_WARNING,
- "%"PRIu64": %s() %s => -1 (%s)", frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path,
- strerror (op_errno));
-
- send_fuse_err (this, finh, op_errno);
- gf_fd_put (priv->fdtable, state->fd_no);
- }
+ gf_log("glusterfs-fuse", GF_LOG_WARNING,
+ "%" PRIu64 ": %s() %s => -1 (%s)", frame->root->unique,
+ gf_fop_list[frame->root->op], state->loc.path,
+ strerror(op_errno));
+
+ send_fuse_err(this, finh, op_errno);
+ gf_fd_put(priv->fdtable, state->fd_no);
+ }
out:
- free_fuse_state (state);
- STACK_DESTROY (frame->root);
- return 0;
+ free_fuse_state(state);
+ STACK_DESTROY(frame->root);
+ return 0;
}
static void
-fuse_do_truncate (fuse_state_t *state)
+fuse_do_truncate(fuse_state_t *state)
{
- if (state->fd) {
- FUSE_FOP (state, fuse_truncate_cbk, GF_FOP_FTRUNCATE,
- ftruncate, state->fd, state->off, state->xdata);
- } else {
- FUSE_FOP (state, fuse_truncate_cbk, GF_FOP_TRUNCATE,
- truncate, &state->loc, state->off, state->xdata);
- }
+ if (state->fd) {
+ FUSE_FOP(state, fuse_truncate_cbk, GF_FOP_FTRUNCATE, ftruncate,
+ state->fd, state->off, state->xdata);
+ } else {
+ FUSE_FOP(state, fuse_truncate_cbk, GF_FOP_TRUNCATE, truncate,
+ &state->loc, state->off, state->xdata);
+ }
- return;
+ return;
}
static int
-fuse_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *statpre, struct iatt *statpost, dict_t *xdata)
-{
- fuse_state_t *state;
- fuse_in_header_t *finh;
- fuse_private_t *priv = NULL;
- struct fuse_attr_out fao;
-
- int op_done = 0;
-
- priv = this->private;
- state = frame->root->state;
- finh = state->finh;
-
- fuse_log_eh(this, "op_ret: %d, op_errno: %d, %"PRIu64", %s() %s => "
- "gfid: %s", op_ret, op_errno, frame->root->unique,
- gf_fop_list[frame->root->op], state->loc.path,
- state->loc.inode ? uuid_utoa (state->loc.inode->gfid) : "");
-
- if (op_ret == 0) {
- gf_log ("glusterfs-fuse", GF_LOG_TRACE,
- "%"PRIu64": %s() %s => %"PRIu64, frame->root->unique,
- gf_fop_list[frame->root->op],
- state->loc.path ? state->loc.path : "ERR",
- statpost->ia_ino);
-
- statpost->ia_blksize = this->ctx->page_size;
- gf_fuse_stat2attr (statpost, &fao.attr, priv->enable_ino32);
-
- fao.attr_valid = calc_timeout_sec (priv->attribute_timeout);
- fao.attr_valid_nsec =
- calc_timeout_nsec (priv->attribute_timeout);
-
- if (state->truncate_needed) {
- fuse_do_truncate (state);
- } else {
+fuse_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *statpre,
+ struct iatt *statpost, dict_t *xdata)
+{
+ fuse_state_t *state;
+ fuse_in_header_t *finh;
+ fuse_private_t *priv = NULL;
+ struct fuse_attr_out fao;
+
+ int op_done = 0;
+
+ priv = this->private;
+ state = frame->root->state;
+ finh = state->finh;
+
+ fuse_log_eh(this,
+