Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ceph: fix error handling in ceph_atomic_open and ceph_lookup

Commit aa60cfc3f7ee broke the error handling in these functions such
that they don't handle non-ENOENT errors from ceph_mdsc_do_request
properly.

Move the checking of -ENOENT out of ceph_handle_snapdir and into the
callers, and if we get a different error, return it immediately.

Fixes: aa60cfc3f7ee ("ceph: don't use d_add in ceph_handle_snapdir")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Jeff Layton and committed by
Ilya Dryomov
7a971e2c 27171ae6

+21 -17
+12 -10
fs/ceph/dir.c
··· 668 668 * Handle lookups for the hidden .snap directory. 669 669 */ 670 670 struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, 671 - struct dentry *dentry, int err) 671 + struct dentry *dentry) 672 672 { 673 673 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); 674 674 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ 675 675 676 676 /* .snap dir? */ 677 - if (err == -ENOENT && 678 - ceph_snap(parent) == CEPH_NOSNAP && 677 + if (ceph_snap(parent) == CEPH_NOSNAP && 679 678 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { 680 679 struct dentry *res; 681 680 struct inode *inode = ceph_get_snapdir(parent); ··· 741 742 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); 742 743 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); 743 744 struct ceph_mds_request *req; 744 - struct dentry *res; 745 745 int op; 746 746 int mask; 747 747 int err; ··· 791 793 req->r_parent = dir; 792 794 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); 793 795 err = ceph_mdsc_do_request(mdsc, NULL, req); 794 - res = ceph_handle_snapdir(req, dentry, err); 795 - if (IS_ERR(res)) { 796 - err = PTR_ERR(res); 797 - } else { 798 - dentry = res; 799 - err = 0; 796 + if (err == -ENOENT) { 797 + struct dentry *res; 798 + 799 + res = ceph_handle_snapdir(req, dentry); 800 + if (IS_ERR(res)) { 801 + err = PTR_ERR(res); 802 + } else { 803 + dentry = res; 804 + err = 0; 805 + } 800 806 } 801 807 dentry = ceph_finish_lookup(req, dentry, err); 802 808 ceph_mdsc_put_request(req); /* will dput(dentry) */
+8 -6
fs/ceph/file.c
··· 742 742 err = ceph_mdsc_do_request(mdsc, 743 743 (flags & (O_CREAT|O_TRUNC)) ? dir : NULL, 744 744 req); 745 - dentry = ceph_handle_snapdir(req, dentry, err); 746 - if (IS_ERR(dentry)) { 747 - err = PTR_ERR(dentry); 748 - goto out_req; 745 + if (err == -ENOENT) { 746 + dentry = ceph_handle_snapdir(req, dentry); 747 + if (IS_ERR(dentry)) { 748 + err = PTR_ERR(dentry); 749 + goto out_req; 750 + } 751 + err = 0; 749 752 } 750 - err = 0; 751 753 752 - if ((flags & O_CREAT) && !req->r_reply_info.head->is_dentry) 754 + if (!err && (flags & O_CREAT) && !req->r_reply_info.head->is_dentry) 753 755 err = ceph_handle_notrace_create(dir, dentry); 754 756 755 757 if (d_in_lookup(dentry)) {
+1 -1
fs/ceph/super.h
··· 1218 1218 extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order); 1219 1219 extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry); 1220 1220 extern struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, 1221 - struct dentry *dentry, int err); 1221 + struct dentry *dentry); 1222 1222 extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, 1223 1223 struct dentry *dentry, int err); 1224 1224