From 09d981409f1379265ee02db9cd5f62672fba4747 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Wed, 10 Oct 2012 09:12:50 -0400 Subject: nfs: do lookup on getattr after brick-status change By doing a lookup, we get a chance to do all of the self-heal checks that would occur if we were using native protocol, and return proper status if the self-heal fails. Best of all, we don't need to misrepresent times. Change-Id: I76477d1e5fce4d83e4029e02fcdd71e81e23110d BUG: 830134 Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/4058 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/nfs/server/src/nfs-fops.c | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'xlators/nfs/server/src/nfs-fops.c') diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c index e2eedf43..5a2cf286 100644 --- a/xlators/nfs/server/src/nfs-fops.c +++ b/xlators/nfs/server/src/nfs-fops.c @@ -353,9 +353,6 @@ out: } \ } while (0) \ - - - /* Fops Layer Explained * The fops layer has three types of functions. They can all be identified by * their names. Here are the three patterns: @@ -388,6 +385,23 @@ nfs_fop_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *local = NULL; fop_lookup_cbk_t progcbk; + char *sh_fail_val = NULL; + + /* + * With native protocol, self-heal failures would be detected during + * open. NFS doesn't issue that open when revalidating cache, so we + * have to check for failures here instead. + */ + if (dict_get_str(xattr,"sh-failed",&sh_fail_val) == 0) { + if (strcmp(sh_fail_val,"1") == 0) { + op_ret = -1; + op_errno = EIO; + } + } + + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } nfl_to_prog_data (local, progcbk, frame); nfs_fop_restore_root_ino (local, op_ret, buf, NULL, NULL, postparent); @@ -759,6 +773,10 @@ nfs_fop_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct nfs_fop_local *nfl = NULL; fop_create_cbk_t progcbk = NULL; + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } + nfl_to_prog_data (nfl, progcbk, frame); nfs_fop_restore_root_ino (nfl, op_ret, buf, NULL, preparent, postparent); @@ -861,6 +879,10 @@ nfs_fop_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct nfs_fop_local *nfl = NULL; fop_mkdir_cbk_t progcbk = NULL; + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } + nfl_to_prog_data (nfl, progcbk, frame); nfs_fop_restore_root_ino (nfl, op_ret, buf, NULL,preparent, postparent); if (progcbk) @@ -910,6 +932,10 @@ nfs_fop_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct nfs_fop_local *nfl = NULL; fop_symlink_cbk_t progcbk = NULL; + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } + nfl_to_prog_data (nfl, progcbk, frame); nfs_fop_restore_root_ino (nfl, op_ret,buf, NULL, preparent, postparent); if (progcbk) @@ -1006,6 +1032,10 @@ nfs_fop_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct nfs_fop_local *nfl = NULL; fop_mknod_cbk_t progcbk = NULL; + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } + nfl_to_prog_data (nfl, progcbk, frame); nfs_fop_restore_root_ino (nfl, op_ret,buf, NULL, preparent, postparent); if (progcbk) @@ -1153,6 +1183,10 @@ nfs_fop_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct nfs_fop_local *nfl = NULL; fop_link_cbk_t progcbk = NULL; + if (op_ret == 0) { + nfs_fix_generation(this,inode); + } + nfl_to_prog_data (nfl, progcbk, frame); nfs_fop_restore_root_ino (nfl, op_ret, buf, NULL, preparent, postparent); -- cgit