diff options
Diffstat (limited to 'xlators/nfs/server/src/nfs-inodes.c')
| -rw-r--r-- | xlators/nfs/server/src/nfs-inodes.c | 176 |
1 files changed, 73 insertions, 103 deletions
diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c index a69e1d791..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 Affero 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 - Affero General Public License for more details. - - You should have received a copy of the GNU Affero 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 @@ -36,7 +27,7 @@ do { \ nflocal = fram->local; \ fram->local = nflocal->proglocal; \ - pcbk = nflocal->progcbk; \ + *VOID(&pcbk) = nflocal->progcbk; \ nfs_fop_local_wipe (nflocal->nfsx, nflocal); \ } while (0) \ @@ -57,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; } @@ -70,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 @@ -89,7 +81,13 @@ do_not_link: 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; } @@ -135,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: 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; } @@ -180,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; @@ -196,14 +200,14 @@ nfs_inode_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, */ 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; @@ -220,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) @@ -242,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; @@ -259,7 +264,7 @@ do_not_link: if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, buf, preoldparent, postoldparent, prenewparent, - postnewparent); + postnewparent, xdata); return 0; } @@ -292,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: 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; } @@ -336,65 +348,9 @@ err: int32_t -nfs_inode_lookup_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 *xattr, - struct iatt *postparent) -{ - struct nfs_fop_local *nfl = NULL; - fop_lookup_cbk_t progcbk = NULL; - inode_t *linked_inode = NULL; - uuid_t rootgfid = {0, }; - - if (op_ret == -1) - goto do_not_link; - - rootgfid[15] = 1; - if (uuid_compare (rootgfid, inode->gfid) == 0) - goto do_not_link; - - nfl = frame->local; - - linked_inode = inode_link (inode, nfl->newparent, nfl->path, buf); - - if (linked_inode) - inode_unref (linked_inode); - -do_not_link: - inodes_nfl_to_prog_data (nfl, progcbk, frame); - if (progcbk) - progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, - xattr, postparent); - return 0; -} - - -int -nfs_inode_lookup (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc, - fop_lookup_cbk_t cbk, void *local) -{ - struct nfs_fop_local *nfl = NULL; - int ret = -EFAULT; - - if ((!nfsx) || (!xl) || (!loc) || (!nfu)) - return -EFAULT; - - nfs_fop_handle_local_init (NULL, nfsx, nfl, cbk, local, ret, err); - nfl_inodes_init (nfl, NULL, NULL, loc->parent, loc->name, NULL); - ret = nfs_fop_lookup (nfsx, xl, nfu, loc, nfs_inode_lookup_cbk, nfl); - -err: - if (ret < 0) - nfs_fop_local_wipe (xl, nfl); - - return ret; -} - - -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; @@ -405,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: inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, preparent, - postparent); + postparent, xdata); return 0; } @@ -441,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; @@ -452,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: inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, preparent, - postparent); + postparent, xdata); return 0; } @@ -490,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: 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; } @@ -540,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: 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; } @@ -586,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); 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; } |
