From a82cfba2795bb15c74b4a8d28bd53ad73a7997c1 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 1 Aug 2014 18:30:32 +0530 Subject: mount/fuse: Handle fd resolution failures Backport of http://review.gluster.org/8402 Problem: Even when the fd resolution failed, the fop is continuing on the new graph which may not have valid inode. This lead to NULL layout subvols in dht which lead to crash in fsync after graph migration. Fix: - Remove resolution error handling in FUSE_FOP as it was only added to handle fd migration failures. - check in fuse_resolve_done for fd resolution failures and fail the fop right away. - loc resolution failures are already handled in the corresponding fops. - Return errno from state->resolve.op_errno in resume functions. - Send error to fuse on frame allocation failures. - Removed unused variable state->resolved - Removed unused macro FUSE_FOP_COOKIE BUG: 1136827 Change-Id: I4010b7fccd7d8caf0ce4e7629e81b605102d8fb4 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/8592 Tested-by: Gluster Build System Reviewed-by: Raghavendra G Reviewed-by: Vijay Bellur --- tests/bugs/bug-1126048.c | 37 +++++++++++++++++++++++++++++++++++++ tests/bugs/bug-1126048.t | 30 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/bugs/bug-1126048.c create mode 100755 tests/bugs/bug-1126048.t (limited to 'tests') diff --git a/tests/bugs/bug-1126048.c b/tests/bugs/bug-1126048.c new file mode 100644 index 00000000000..2282bb2025e --- /dev/null +++ b/tests/bugs/bug-1126048.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +#include + +/* + * This function opens a file and to trigger migration failure, unlinks the + * file and performs graph switch (cmd passed in argv). If everything goes fine, + * fsync should fail without crashing the mount process. + */ +int +main (int argc, char **argv) +{ + int ret = 0; + int fd = 0; + char *cmd = argv[1]; + + printf ("cmd is: %s\n", cmd); + fd = open("a.txt", O_CREAT|O_RDWR); + if (fd < 0) + printf ("open failed: %s\n", strerror(errno)); + + ret = unlink("a.txt"); + if (ret < 0) + printf ("unlink failed: %s\n", strerror(errno)); + if (write (fd, "abc", 3) < 0) + printf ("Not able to print %s\n", strerror (errno)); + system(cmd); + sleep(1); //No way to confirm graph switch so sleep 1 + ret = fsync(fd); + if (ret < 0) + printf ("Not able to fsync %s\n", strerror (errno)); + return 0; +} diff --git a/tests/bugs/bug-1126048.t b/tests/bugs/bug-1126048.t new file mode 100755 index 00000000000..53c8ced4f96 --- /dev/null +++ b/tests/bugs/bug-1126048.t @@ -0,0 +1,30 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +function grep_for_ebadf { + $M0/bug-1126048 "gluster --mode=script --wignore volume add-brick $V0 $H0:$B0/brick2" | grep -i "Bad file descriptor" +} +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/brick1; +EXPECT 'Created' volinfo_field $V0 'Status'; + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST glusterfs -s $H0 --volfile-id=$V0 $M0 --direct-io-mode=yes + +build_tester $(dirname $0)/bug-1126048.c + +TEST cp $(dirname $0)/bug-1126048 $M0 +cd $M0 +TEST grep_for_ebadf +TEST ls -l $M0 +cd - +TEST rm -f $(dirname $0)/bug-1126048 +cleanup; -- cgit