diff options
author | Jeff Layton <jlayton@kernel.org> | 2021-02-25 15:04:15 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2021-03-08 10:19:36 -0500 |
commit | 3e10a15ffc8d77f05e655d14fd48c0b790dede35 (patch) | |
tree | a17d57ad4dea11482c47292192fa89c548dcf2fd /fs/ceph/inode.c | |
parent | 6e3e2c4362e41a2f18e3f7a5ad81bd2f49a47b85 (diff) | |
download | lwn-3e10a15ffc8d77f05e655d14fd48c0b790dede35.tar.gz lwn-3e10a15ffc8d77f05e655d14fd48c0b790dede35.zip |
ceph: fix up error handling with snapdirs
There are several warts in the snapdir error handling. The -EOPNOTSUPP
return in __snapfh_to_dentry is currently lost, and the call to
ceph_handle_snapdir is not currently checked at all.
Fix all of this up and eliminate a BUG_ON in ceph_get_snapdir. We can
handle that case with a warning and return an error.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r-- | fs/ceph/inode.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 156f849f5385..5db7bf4c6a26 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -78,9 +78,21 @@ struct inode *ceph_get_snapdir(struct inode *parent) struct inode *inode = ceph_get_inode(parent->i_sb, vino); struct ceph_inode_info *ci = ceph_inode(inode); - BUG_ON(!S_ISDIR(parent->i_mode)); if (IS_ERR(inode)) return inode; + + if (!S_ISDIR(parent->i_mode)) { + pr_warn_once("bad snapdir parent type (mode=0%o)\n", + parent->i_mode); + return ERR_PTR(-ENOTDIR); + } + + if (!(inode->i_state & I_NEW) && !S_ISDIR(inode->i_mode)) { + pr_warn_once("bad snapdir inode type (mode=0%o)\n", + inode->i_mode); + return ERR_PTR(-ENOTDIR); + } + inode->i_mode = parent->i_mode; inode->i_uid = parent->i_uid; inode->i_gid = parent->i_gid; |