diff options
Diffstat (limited to 'xlators/nfs/server/src/nfs-inodes.c')
| -rw-r--r-- | xlators/nfs/server/src/nfs-inodes.c | 146 |
1 files changed, 90 insertions, 56 deletions
diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c index 4b8bad717..63d5e8a19 100644 --- a/xlators/nfs/server/src/nfs-inodes.c +++ b/xlators/nfs/server/src/nfs-inodes.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H @@ -32,6 +23,14 @@ #include <libgen.h> +#define inodes_nfl_to_prog_data(nflocal, pcbk, fram) \ + do { \ + nflocal = fram->local; \ + fram->local = nflocal->proglocal; \ + *VOID(&pcbk) = nflocal->progcbk; \ + nfs_fop_local_wipe (nflocal->nfsx, nflocal); \ + } while (0) \ + void nfl_inodes_init (struct nfs_fop_local *nfl, inode_t *inode, inode_t *parent, inode_t *newparent, const char *name, const char *newname) @@ -49,10 +48,10 @@ nfl_inodes_init (struct nfs_fop_local *nfl, inode_t *inode, inode_t *parent, nfl->newparent = inode_ref (newparent); if (name) - strcpy (nfl->path, name); + strncpy (nfl->path, name, NFS_NAME_MAX); if (newname) - strcpy (nfl->newpath, newname); + strncpy (nfl->newpath, newname, NFS_NAME_MAX); return; } @@ -62,15 +61,16 @@ int32_t nfs_inode_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode , struct iatt *buf, struct iatt *preparent, - struct iatt *postparent) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = frame->local; fop_create_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: /* NFS does not need it, upper layers should not expect the pointer to @@ -78,10 +78,16 @@ do_not_link: */ fd_unref (fd); - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, fd, inode, buf, - preparent, postparent); + preparent, postparent, xdata); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -127,21 +133,27 @@ int32_t nfs_inode_mkdir_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) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = frame->local; fop_mkdir_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } return 0; } @@ -172,7 +184,7 @@ err: int32_t nfs_inode_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd) + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; @@ -186,16 +198,16 @@ nfs_inode_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* else fd_bind (fd); */ - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) - progcbk (frame, cookie, this, op_ret, op_errno, fd); + progcbk (frame, cookie, this, op_ret, op_errno, fd, xdata); return 0; } int nfs_inode_open (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc, - int32_t flags, int32_t wbflags, fop_open_cbk_t cbk, void *local) + int32_t flags, fop_open_cbk_t cbk, void *local) { struct nfs_fop_local *nfl = NULL; fd_t *newfd = NULL; @@ -212,7 +224,7 @@ nfs_inode_open (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc, } nfs_fop_handle_local_init (NULL, nfsx, nfl, cbk, local, ret, fd_err); - ret = nfs_fop_open (nfsx, xl, nfu, loc, flags, newfd, wbflags, + ret = nfs_fop_open (nfsx, xl, nfu, loc, flags, newfd, nfs_inode_open_cbk, nfl); if (ret < 0) @@ -234,7 +246,8 @@ int32_t nfs_inode_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *buf, struct iatt *preoldparent, struct iatt *postoldparent, - struct iatt *prenewparent, struct iatt *postnewparent) + struct iatt *prenewparent, struct iatt *postnewparent, + dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_rename_cbk_t progcbk = NULL; @@ -247,11 +260,11 @@ nfs_inode_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfl->newpath, nfl->inode, buf); do_not_link: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, buf, preoldparent, postoldparent, prenewparent, - postnewparent); + postnewparent, xdata); return 0; } @@ -284,22 +297,29 @@ int32_t nfs_inode_link_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) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_link_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; nfl = frame->local; - inode_link (inode, nfl->newparent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->newparent, nfl->path, buf); do_not_link: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -330,7 +350,7 @@ err: int32_t nfs_inode_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *preparent, - struct iatt *postparent) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_unlink_cbk_t progcbk = NULL; @@ -341,12 +361,13 @@ nfs_inode_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto do_not_unlink; inode_unlink (nfl->inode, nfl->parent, nfl->path); + inode_forget (nfl->inode, 0); do_not_unlink: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, preparent, - postparent); + postparent, xdata); return 0; } @@ -377,7 +398,7 @@ err: int32_t nfs_inode_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *preparent, - struct iatt *postparent) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_rmdir_cbk_t progcbk = NULL; @@ -388,12 +409,13 @@ nfs_inode_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto do_not_unlink; inode_unlink (nfl->inode, nfl->parent, nfl->path); + inode_forget (nfl->inode, 0); do_not_unlink: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, preparent, - postparent); + postparent, xdata); return 0; } @@ -426,23 +448,30 @@ int32_t nfs_inode_mknod_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) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_mknod_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; nfl = frame->local; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -476,22 +505,28 @@ int32_t nfs_inode_symlink_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) + struct iatt *postparent, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_symlink_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; nfl = frame->local; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } return 0; } @@ -522,21 +557,20 @@ err: int32_t nfs_inode_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd) + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { struct nfs_fop_local *nfl = NULL; fop_open_cbk_t progcbk = NULL; - if ((op_ret == -1) && (fd)) - fd_unref (fd); - else + if (op_ret != -1) fd_bind (fd); - nfl_to_prog_data (nfl, progcbk, frame); + inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) - progcbk (frame, cookie, this, op_ret, op_errno, fd); + progcbk (frame, cookie, this, op_ret, op_errno, fd, xdata); + return 0; } |
