2011-10-30 09:11:37 +04:00
|
|
|
/* $NetBSD: subr.c,v 1.14 2011/10/30 05:11:37 manu Exp $ */
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
/*-
|
- Implement proper unprivilegied user permission verifications
Verification is now done in the lookup method, as it is the way to
go. Of course there are corner cases, such as the sticky bit which
need special handling in the remove method.
- Set full fsidx in vftstat method
- Do not pass O_APPEND to the filesystem. FUSE always sends the
write offset, so setting O_APPEND is useless. If the filesystem
uses it in an open(2) system call, it will even cause file
corruptions, since offsets given to pwrite(2) will be ignored.
This fix allows glusterfs to host a NetBSD ./build.sh -o build
- Do not use the FUSE access method, use getattr and check for
permission on our own. The problem is that a FUSE filesystem will
typically use the Linux-specific setfsuid() to perform access
control. If that is missing, any chack is likely to occur on
behalf of the user running the filesystem (typically root), causing
access method to return wrong information.
- When possible, avoid performing a getattr method call and use
cached value in puffs_node instead. We still retreive the latest
value by calling getattr when performing append write operation,
to minimize the chances that another writer appended since the
last time we did.
- Update puffs_node cached file size in write method
- Remove unused argument to perfuse_destroy_pn()
2011-04-25 08:54:53 +04:00
|
|
|
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
|
2010-08-25 11:16:00 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sysexits.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <puffs.h>
|
|
|
|
#include <paths.h>
|
2011-06-28 20:19:16 +04:00
|
|
|
#include <sys/extattr.h>
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
#include "perfuse_priv.h"
|
|
|
|
|
2011-06-28 20:19:16 +04:00
|
|
|
struct perfuse_ns_map {
|
|
|
|
const char *pnm_ns;
|
|
|
|
const size_t pnm_nslen;
|
|
|
|
const int pnm_native_ns;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PERFUSE_NS_MAP(ns, native_ns) \
|
|
|
|
{ ns ".", sizeof(ns), native_ns }
|
|
|
|
|
2010-10-03 09:46:47 +04:00
|
|
|
static size_t node_path(puffs_cookie_t, char *, size_t);
|
|
|
|
|
2010-08-25 11:16:00 +04:00
|
|
|
struct puffs_node *
|
2010-10-03 09:46:47 +04:00
|
|
|
perfuse_new_pn(pu, name, parent)
|
2010-08-25 11:16:00 +04:00
|
|
|
struct puffs_usermount *pu;
|
2010-10-03 09:46:47 +04:00
|
|
|
const char *name;
|
2010-08-25 11:16:00 +04:00
|
|
|
struct puffs_node *parent;
|
|
|
|
{
|
|
|
|
struct puffs_node *pn;
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
|
|
|
|
if ((pnd = malloc(sizeof(*pnd))) == NULL)
|
2011-08-14 03:12:15 +04:00
|
|
|
DERR(EX_OSERR, "%s: malloc failed", __func__);
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
if ((pn = puffs_pn_new(pu, pnd)) == NULL)
|
2011-08-14 03:12:15 +04:00
|
|
|
DERR(EX_SOFTWARE, "%s: puffs_pn_new failed", __func__);
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
(void)memset(pnd, 0, sizeof(*pnd));
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
pnd->pnd_rfh = FUSE_UNKNOWN_FH;
|
|
|
|
pnd->pnd_wfh = FUSE_UNKNOWN_FH;
|
2011-10-30 09:11:37 +04:00
|
|
|
pnd->pnd_nodeid = PERFUSE_UNKNOWN_NODEID;
|
2010-08-25 11:16:00 +04:00
|
|
|
pnd->pnd_nlookup = 1;
|
|
|
|
pnd->pnd_parent = parent;
|
2010-09-20 11:00:21 +04:00
|
|
|
pnd->pnd_pn = (puffs_cookie_t)pn;
|
2010-10-03 09:46:47 +04:00
|
|
|
(void)strlcpy(pnd->pnd_name, name, MAXPATHLEN);
|
2010-08-25 11:16:00 +04:00
|
|
|
TAILQ_INIT(&pnd->pnd_pcq);
|
2010-10-03 09:46:47 +04:00
|
|
|
TAILQ_INIT(&pnd->pnd_children);
|
|
|
|
|
|
|
|
if (parent != NULL) {
|
|
|
|
struct perfuse_node_data *parent_pnd;
|
2010-08-25 11:16:00 +04:00
|
|
|
|
2010-10-03 09:46:47 +04:00
|
|
|
parent_pnd = PERFUSE_NODE_DATA(parent);
|
|
|
|
TAILQ_INSERT_TAIL(&parent_pnd->pnd_children, pnd, pnd_next);
|
2010-09-20 11:00:21 +04:00
|
|
|
|
2010-10-03 09:46:47 +04:00
|
|
|
parent_pnd->pnd_childcount++;
|
|
|
|
}
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
return pn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
- Implement proper unprivilegied user permission verifications
Verification is now done in the lookup method, as it is the way to
go. Of course there are corner cases, such as the sticky bit which
need special handling in the remove method.
- Set full fsidx in vftstat method
- Do not pass O_APPEND to the filesystem. FUSE always sends the
write offset, so setting O_APPEND is useless. If the filesystem
uses it in an open(2) system call, it will even cause file
corruptions, since offsets given to pwrite(2) will be ignored.
This fix allows glusterfs to host a NetBSD ./build.sh -o build
- Do not use the FUSE access method, use getattr and check for
permission on our own. The problem is that a FUSE filesystem will
typically use the Linux-specific setfsuid() to perform access
control. If that is missing, any chack is likely to occur on
behalf of the user running the filesystem (typically root), causing
access method to return wrong information.
- When possible, avoid performing a getattr method call and use
cached value in puffs_node instead. We still retreive the latest
value by calling getattr when performing append write operation,
to minimize the chances that another writer appended since the
last time we did.
- Update puffs_node cached file size in write method
- Remove unused argument to perfuse_destroy_pn()
2011-04-25 08:54:53 +04:00
|
|
|
perfuse_destroy_pn(pn)
|
2010-08-25 11:16:00 +04:00
|
|
|
struct puffs_node *pn;
|
|
|
|
{
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
|
2010-09-20 11:00:21 +04:00
|
|
|
pnd = PERFUSE_NODE_DATA(pn);
|
|
|
|
|
2010-10-03 09:46:47 +04:00
|
|
|
if (pnd->pnd_parent != NULL) {
|
|
|
|
struct perfuse_node_data *parent_pnd;
|
|
|
|
|
|
|
|
parent_pnd = PERFUSE_NODE_DATA(pnd->pnd_parent);
|
|
|
|
TAILQ_REMOVE(&parent_pnd->pnd_children, pnd, pnd_next);
|
|
|
|
}
|
2010-09-20 11:00:21 +04:00
|
|
|
|
2010-08-25 11:16:00 +04:00
|
|
|
if ((pnd = puffs_pn_getpriv(pn)) != NULL) {
|
|
|
|
if (pnd->pnd_parent != NULL)
|
|
|
|
PERFUSE_NODE_DATA(pnd->pnd_parent)->pnd_childcount--;
|
|
|
|
|
|
|
|
if (pnd->pnd_dirent != NULL)
|
|
|
|
free(pnd->pnd_dirent);
|
|
|
|
|
|
|
|
if (pnd->pnd_all_fd != NULL)
|
|
|
|
free(pnd->pnd_all_fd);
|
|
|
|
#ifdef PERFUSE_DEBUG
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
if (pnd->pnd_flags & PND_OPEN)
|
|
|
|
DERRX(EX_SOFTWARE, "%s: file open", __func__);
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
if (!TAILQ_EMPTY(&pnd->pnd_pcq))
|
|
|
|
DERRX(EX_SOFTWARE, "%s: non empty pnd_pcq", __func__);
|
|
|
|
#endif /* PERFUSE_DEBUG */
|
|
|
|
|
|
|
|
free(pnd);
|
|
|
|
}
|
|
|
|
|
2010-09-29 12:01:10 +04:00
|
|
|
puffs_pn_put(pn);
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
== file close operations ==
- use PUFFS_KFLAG_WTCACHE to puffs_init so that all writes are
immediatly send to the filesystem, and we do not have anymore write
after inactive. As a consequence, we can close files at inactive
stage, and there is not any concern left with files opened at
create time. We also do not have anymore to open ourselves in readdir and
fsync.
- Fsync on close (inactive stage). That makes sure we will not need to
do these operations once the file is closed (FUSE want an open file).
short sircuit the request that come after the close, bu not fsinc'ing
closed files,
- Use PUFFS_KFLAG_IAONDEMAND to get less inactive calls
== Removed nodes ==
- more ENOENT retunred for operations on removed node (but there
are probably some still missing): getattr, ooen, setattr, fsync
- set PND_REMOVE before sending the UNLINK/RMDIR operations so that we avoid
races during UNLINK completion. Also set PND_REMOVED on node we overwirte
in rename
== Filehandle fixes ==
- queue open operation to avoid getting two fh for one file
- set FH in getattr, if the file is open
- Just requires a read FH for fsyncdir, as we always opendir in read
mode. Ok, this is misleading :-)
== Misc ==
- do not set FUSE_FATTR_ATIME_NOW in setattr, as we provide the time
- short circuit nilpotent operations in setattr
- add a filename diagnostic flag to dump file names
2010-09-23 20:02:34 +04:00
|
|
|
perfuse_new_fh(opc, fh, mode)
|
2010-08-25 11:16:00 +04:00
|
|
|
puffs_cookie_t opc;
|
|
|
|
uint64_t fh;
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
int mode;
|
2010-08-25 11:16:00 +04:00
|
|
|
{
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
|
|
|
|
pnd = PERFUSE_NODE_DATA(opc);
|
|
|
|
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
if (mode & FWRITE) {
|
|
|
|
if (pnd->pnd_flags & PND_WFH)
|
|
|
|
DERRX(EX_SOFTWARE, "%s: opc = %p, write fh already set",
|
|
|
|
__func__, (void *)opc);
|
|
|
|
pnd->pnd_wfh = fh;
|
|
|
|
pnd->pnd_flags |= PND_WFH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode & FREAD) {
|
|
|
|
if (pnd->pnd_flags & PND_RFH)
|
|
|
|
DERRX(EX_SOFTWARE, "%s: opc = %p, read fh already set",
|
|
|
|
__func__, (void *)opc);
|
|
|
|
pnd->pnd_rfh = fh;
|
|
|
|
pnd->pnd_flags |= PND_RFH;
|
|
|
|
}
|
2010-08-25 11:16:00 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
perfuse_destroy_fh(opc, fh)
|
|
|
|
puffs_cookie_t opc;
|
|
|
|
uint64_t fh;
|
|
|
|
{
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
|
|
|
|
pnd = PERFUSE_NODE_DATA(opc);
|
|
|
|
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
if (fh == pnd->pnd_rfh) {
|
|
|
|
if (!(pnd->pnd_flags & PND_RFH) && (fh != FUSE_UNKNOWN_FH))
|
|
|
|
DERRX(EX_SOFTWARE,
|
|
|
|
"%s: opc = %p, unset rfh = %"PRIx64"",
|
|
|
|
__func__, (void *)opc, fh);
|
|
|
|
pnd->pnd_rfh = FUSE_UNKNOWN_FH;
|
|
|
|
pnd->pnd_flags &= ~PND_RFH;
|
2010-08-25 11:16:00 +04:00
|
|
|
}
|
|
|
|
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
if (fh == pnd->pnd_wfh) {
|
|
|
|
if (!(pnd->pnd_flags & PND_WFH) && (fh != FUSE_UNKNOWN_FH))
|
|
|
|
DERRX(EX_SOFTWARE,
|
|
|
|
"%s: opc = %p, unset wfh = %"PRIx64"",
|
|
|
|
__func__, (void *)opc, fh);
|
|
|
|
pnd->pnd_wfh = FUSE_UNKNOWN_FH;
|
|
|
|
pnd->pnd_flags &= ~PND_WFH;
|
|
|
|
}
|
2010-08-26 17:29:01 +04:00
|
|
|
|
2010-08-25 11:16:00 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
perfuse_get_fh(opc, mode)
|
2010-08-25 11:16:00 +04:00
|
|
|
puffs_cookie_t opc;
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
int mode;
|
2010-08-25 11:16:00 +04:00
|
|
|
{
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
|
|
|
|
pnd = PERFUSE_NODE_DATA(opc);
|
|
|
|
|
== file close operations ==
- use PUFFS_KFLAG_WTCACHE to puffs_init so that all writes are
immediatly send to the filesystem, and we do not have anymore write
after inactive. As a consequence, we can close files at inactive
stage, and there is not any concern left with files opened at
create time. We also do not have anymore to open ourselves in readdir and
fsync.
- Fsync on close (inactive stage). That makes sure we will not need to
do these operations once the file is closed (FUSE want an open file).
short sircuit the request that come after the close, bu not fsinc'ing
closed files,
- Use PUFFS_KFLAG_IAONDEMAND to get less inactive calls
== Removed nodes ==
- more ENOENT retunred for operations on removed node (but there
are probably some still missing): getattr, ooen, setattr, fsync
- set PND_REMOVE before sending the UNLINK/RMDIR operations so that we avoid
races during UNLINK completion. Also set PND_REMOVED on node we overwirte
in rename
== Filehandle fixes ==
- queue open operation to avoid getting two fh for one file
- set FH in getattr, if the file is open
- Just requires a read FH for fsyncdir, as we always opendir in read
mode. Ok, this is misleading :-)
== Misc ==
- do not set FUSE_FATTR_ATIME_NOW in setattr, as we provide the time
- short circuit nilpotent operations in setattr
- add a filename diagnostic flag to dump file names
2010-09-23 20:02:34 +04:00
|
|
|
if (mode & FWRITE) {
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
if (pnd->pnd_flags & PND_WFH)
|
|
|
|
return pnd->pnd_wfh;
|
== file close operations ==
- use PUFFS_KFLAG_WTCACHE to puffs_init so that all writes are
immediatly send to the filesystem, and we do not have anymore write
after inactive. As a consequence, we can close files at inactive
stage, and there is not any concern left with files opened at
create time. We also do not have anymore to open ourselves in readdir and
fsync.
- Fsync on close (inactive stage). That makes sure we will not need to
do these operations once the file is closed (FUSE want an open file).
short sircuit the request that come after the close, bu not fsinc'ing
closed files,
- Use PUFFS_KFLAG_IAONDEMAND to get less inactive calls
== Removed nodes ==
- more ENOENT retunred for operations on removed node (but there
are probably some still missing): getattr, ooen, setattr, fsync
- set PND_REMOVE before sending the UNLINK/RMDIR operations so that we avoid
races during UNLINK completion. Also set PND_REMOVED on node we overwirte
in rename
== Filehandle fixes ==
- queue open operation to avoid getting two fh for one file
- set FH in getattr, if the file is open
- Just requires a read FH for fsyncdir, as we always opendir in read
mode. Ok, this is misleading :-)
== Misc ==
- do not set FUSE_FATTR_ATIME_NOW in setattr, as we provide the time
- short circuit nilpotent operations in setattr
- add a filename diagnostic flag to dump file names
2010-09-23 20:02:34 +04:00
|
|
|
}
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
|
|
|
|
if (mode & FREAD) {
|
|
|
|
if (pnd->pnd_flags & PND_RFH)
|
|
|
|
return pnd->pnd_rfh;
|
|
|
|
|
|
|
|
if (pnd->pnd_flags & PND_WFH)
|
|
|
|
return pnd->pnd_wfh;
|
== file close operations ==
- use PUFFS_KFLAG_WTCACHE to puffs_init so that all writes are
immediatly send to the filesystem, and we do not have anymore write
after inactive. As a consequence, we can close files at inactive
stage, and there is not any concern left with files opened at
create time. We also do not have anymore to open ourselves in readdir and
fsync.
- Fsync on close (inactive stage). That makes sure we will not need to
do these operations once the file is closed (FUSE want an open file).
short sircuit the request that come after the close, bu not fsinc'ing
closed files,
- Use PUFFS_KFLAG_IAONDEMAND to get less inactive calls
== Removed nodes ==
- more ENOENT retunred for operations on removed node (but there
are probably some still missing): getattr, ooen, setattr, fsync
- set PND_REMOVE before sending the UNLINK/RMDIR operations so that we avoid
races during UNLINK completion. Also set PND_REMOVED on node we overwirte
in rename
== Filehandle fixes ==
- queue open operation to avoid getting two fh for one file
- set FH in getattr, if the file is open
- Just requires a read FH for fsyncdir, as we always opendir in read
mode. Ok, this is misleading :-)
== Misc ==
- do not set FUSE_FATTR_ATIME_NOW in setattr, as we provide the time
- short circuit nilpotent operations in setattr
- add a filename diagnostic flag to dump file names
2010-09-23 20:02:34 +04:00
|
|
|
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
}
|
2010-08-25 11:16:00 +04:00
|
|
|
|
- Postpone file close at reclaim time, since NetBSD sends fsync and
setattr(mtime, ctime) after close, while FUSE expects the file
to be open for these operations
- remove unused argument to node_mk_common()
- remove requeued requests when they are executed, not when they
are tagged for schedule
- try to make filehandle management simplier, by keeping track of only
one read and one write filehandle (the latter being really read/write).
- when CREATE is not available, we use the MKNOD/OPEN path. Fix a
bug here where we opened the parent directory instead of the node:
add the missing lookup of the mknod'ed node.
- lookup file we just created: glusterfs does not really see them
otherwise.
- open file when doing setattr(mtime, ctime) on non open files, as
some filesystems seems to require it.
- Do not flush pagecache for removed nodes
- Keep track of read/write operations in progress, and at reclaim
time, make sure they are over before closing and forgeting the file.
2010-09-03 11:15:18 +04:00
|
|
|
return FUSE_UNKNOWN_FH;
|
2010-08-25 11:16:00 +04:00
|
|
|
}
|
|
|
|
|
2010-10-03 09:46:47 +04:00
|
|
|
static size_t
|
|
|
|
node_path(opc, buf, buflen)
|
|
|
|
puffs_cookie_t opc;
|
|
|
|
char *buf;
|
|
|
|
size_t buflen;
|
|
|
|
{
|
|
|
|
struct perfuse_node_data *pnd;
|
|
|
|
size_t written;
|
|
|
|
|
|
|
|
pnd = PERFUSE_NODE_DATA(opc);
|
|
|
|
if (pnd->pnd_parent == opc)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
written = node_path(pnd->pnd_parent, buf, buflen);
|
|
|
|
buf += written;
|
|
|
|
buflen -= written;
|
|
|
|
|
|
|
|
return written + snprintf(buf, buflen, "/%s", pnd->pnd_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
perfuse_node_path(opc)
|
|
|
|
puffs_cookie_t opc;
|
|
|
|
{
|
|
|
|
static char buf[MAXPATHLEN + 1];
|
|
|
|
|
|
|
|
if (node_path(opc, buf, sizeof(buf)) == 0)
|
|
|
|
sprintf(buf, "/");
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
2011-06-28 20:19:16 +04:00
|
|
|
|
|
|
|
const char *
|
|
|
|
perfuse_native_ns(attrnamespace, attrname, fuse_attrname)
|
|
|
|
const int attrnamespace;
|
|
|
|
const char *attrname;
|
|
|
|
char *fuse_attrname;
|
|
|
|
{
|
|
|
|
const struct perfuse_ns_map *pnm;
|
|
|
|
const struct perfuse_ns_map perfuse_ns_map[] = {
|
|
|
|
PERFUSE_NS_MAP("trusted", EXTATTR_NAMESPACE_SYSTEM),
|
|
|
|
PERFUSE_NS_MAP("security", EXTATTR_NAMESPACE_SYSTEM),
|
|
|
|
PERFUSE_NS_MAP("system", EXTATTR_NAMESPACE_SYSTEM),
|
|
|
|
PERFUSE_NS_MAP("user", EXTATTR_NAMESPACE_USER),
|
|
|
|
{ NULL, 0, EXTATTR_NAMESPACE_USER },
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If attribute has a reserved Linux namespace (e.g.: trusted.foo)
|
|
|
|
* and that namespace matches the requested native namespace
|
|
|
|
* we have nothing to do.
|
|
|
|
* Otherwise we have either:
|
|
|
|
* (system|trusted|security).* with user namespace: prepend user.
|
|
|
|
* anything else with system napespace: prepend system.
|
|
|
|
*/
|
|
|
|
for (pnm = perfuse_ns_map; pnm->pnm_ns; pnm++) {
|
|
|
|
if (strncmp(attrname, pnm->pnm_ns, pnm->pnm_nslen) != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (attrnamespace == pnm->pnm_native_ns)
|
|
|
|
return attrname;
|
|
|
|
|
|
|
|
/* (system|trusted|security).* with user namespace */
|
|
|
|
if (attrnamespace == EXTATTR_NAMESPACE_USER) {
|
|
|
|
(void)snprintf(fuse_attrname, LINUX_XATTR_NAME_MAX,
|
|
|
|
"user.%s", attrname);
|
|
|
|
return (const char *)fuse_attrname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* anything else with system napespace */
|
|
|
|
if (attrnamespace == EXTATTR_NAMESPACE_SYSTEM) {
|
|
|
|
(void)snprintf(fuse_attrname, LINUX_XATTR_NAME_MAX,
|
|
|
|
"system.%s", attrname);
|
|
|
|
return (const char *)fuse_attrname;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (const char *)attrname;
|
|
|
|
}
|