aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2012-06-05 09:10:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:33:26 -0400
commitf60dc3db6e24b7c36445cf1feb56b34c799074b3 (patch)
tree594d45bf42e498c9c30fd30c93f97a3cf8827851
parent77d660a8a83036432dc33f092a367d06563d233e (diff)
vfs: do_last(): clean up retry
Move the lookup retry logic to the bottom of the function to make the normal case simpler to read. Reported-by: David Howells <dhowells@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namei.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 6bdb8d732538..183a769537fe 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2614,22 +2614,11 @@ finish_open_created:
2614 goto exit; 2614 goto exit;
2615 od->mnt = nd->path.mnt; 2615 od->mnt = nd->path.mnt;
2616 filp = finish_open(od, nd->path.dentry, NULL); 2616 filp = finish_open(od, nd->path.dentry, NULL);
2617 if (filp == ERR_PTR(-EOPENSTALE) && save_parent.dentry && !retried) { 2617 if (IS_ERR(filp)) {
2618 BUG_ON(save_parent.dentry != dir); 2618 if (filp == ERR_PTR(-EOPENSTALE))
2619 path_put(&nd->path); 2619 goto stale_open;
2620 nd->path = save_parent;
2621 nd->inode = dir->d_inode;
2622 save_parent.mnt = NULL;
2623 save_parent.dentry = NULL;
2624 if (want_write) {
2625 mnt_drop_write(nd->path.mnt);
2626 want_write = false;
2627 }
2628 retried = true;
2629 goto retry_lookup;
2630 }
2631 if (IS_ERR(filp))
2632 goto out; 2620 goto out;
2621 }
2633 error = open_check_o_direct(filp); 2622 error = open_check_o_direct(filp);
2634 if (error) 2623 if (error)
2635 goto exit_fput; 2624 goto exit_fput;
@@ -2659,6 +2648,23 @@ exit_fput:
2659 fput(filp); 2648 fput(filp);
2660 goto exit; 2649 goto exit;
2661 2650
2651stale_open:
2652 /* If no saved parent or already retried then can't retry */
2653 if (!save_parent.dentry || retried)
2654 goto out;
2655
2656 BUG_ON(save_parent.dentry != dir);
2657 path_put(&nd->path);
2658 nd->path = save_parent;
2659 nd->inode = dir->d_inode;
2660 save_parent.mnt = NULL;
2661 save_parent.dentry = NULL;
2662 if (want_write) {
2663 mnt_drop_write(nd->path.mnt);
2664 want_write = false;
2665 }
2666 retried = true;
2667 goto retry_lookup;
2662} 2668}
2663 2669
2664static struct file *path_openat(int dfd, const char *pathname, 2670static struct file *path_openat(int dfd, const char *pathname,