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.

fuse_ctl_add_conn(): fix nlink breakage in case of early failure

fuse_ctl_remove_conn() used to decrement the link count of root
manually; that got subsumed by simple_recursive_removal(), but
in case when subdirectory creation has failed the latter won't
get called.

Just move the modification of parent's link count into
fuse_ctl_add_dentry() to keep the things simple. Allows to
get rid of the nlink argument as well...

Fixes: fcaac5b42768 "fuse_ctl: use simple_recursive_removal()"
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro c460192a e9a6fb0b

+10 -9
+10 -9
fs/fuse/control.c
··· 205 205 206 206 static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, 207 207 struct fuse_conn *fc, 208 - const char *name, 209 - int mode, int nlink, 208 + const char *name, int mode, 210 209 const struct inode_operations *iop, 211 210 const struct file_operations *fop) 212 211 { ··· 231 232 if (iop) 232 233 inode->i_op = iop; 233 234 inode->i_fop = fop; 234 - set_nlink(inode, nlink); 235 + if (S_ISDIR(mode)) { 236 + inc_nlink(d_inode(parent)); 237 + inc_nlink(inode); 238 + } 235 239 inode->i_private = fc; 236 240 d_add(dentry, inode); 237 241 ··· 254 252 return 0; 255 253 256 254 parent = fuse_control_sb->s_root; 257 - inc_nlink(d_inode(parent)); 258 255 sprintf(name, "%u", fc->dev); 259 - parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, 256 + parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 260 257 &simple_dir_inode_operations, 261 258 &simple_dir_operations); 262 259 if (!parent) 263 260 goto err; 264 261 265 - if (!fuse_ctl_add_dentry(parent, fc, "waiting", S_IFREG | 0400, 1, 262 + if (!fuse_ctl_add_dentry(parent, fc, "waiting", S_IFREG | 0400, 266 263 NULL, &fuse_ctl_waiting_ops) || 267 - !fuse_ctl_add_dentry(parent, fc, "abort", S_IFREG | 0200, 1, 264 + !fuse_ctl_add_dentry(parent, fc, "abort", S_IFREG | 0200, 268 265 NULL, &fuse_ctl_abort_ops) || 269 266 !fuse_ctl_add_dentry(parent, fc, "max_background", S_IFREG | 0600, 270 - 1, NULL, &fuse_conn_max_background_ops) || 267 + NULL, &fuse_conn_max_background_ops) || 271 268 !fuse_ctl_add_dentry(parent, fc, "congestion_threshold", 272 - S_IFREG | 0600, 1, NULL, 269 + S_IFREG | 0600, NULL, 273 270 &fuse_conn_congestion_threshold_ops)) 274 271 goto err; 275 272