Skip to content

Commit

Permalink
[PATCH] r/o bind mount prepwork: inc_nlink() helper
Browse files Browse the repository at this point in the history
This is mostly included for parity with dec_nlink(), where we will have some
more hooks.  This one should stay pretty darn straightforward for now.

Signed-off-by: Dave Hansen <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hansendc authored and Linus Torvalds committed Oct 1, 2006
1 parent 9a53c3a commit d8c76e6
Show file tree
Hide file tree
Showing 37 changed files with 80 additions and 75 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/ipath/ipath_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
inode->i_private = data;
if ((mode & S_IFMT) == S_IFDIR) {
inode->i_op = &simple_dir_inode_operations;
inode->i_nlink++;
dir->i_nlink++;
inc_nlink(inode);
inc_nlink(dir);
}

inode->i_fop = fops;
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/core/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
break;
}
}
Expand Down Expand Up @@ -295,7 +295,7 @@ static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode)
mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
res = usbfs_mknod (dir, dentry, mode, 0);
if (!res)
dir->i_nlink++;
inc_nlink(dir);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
inode->i_op = &v9fs_symlink_inode_operations;
break;
case S_IFDIR:
inode->i_nlink++;
inc_nlink(inode);
if(v9ses->extended)
inode->i_op = &v9fs_dir_inode_operations_ext;
else
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
ent->dentry = dentry;
autofs_hash_insert(dh,ent);

dir->i_nlink++;
inc_nlink(dir);
d_instantiate(dentry, iget(dir->i_sb,ino));
unlock_kernel();

Expand Down
2 changes: 1 addition & 1 deletion fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (p_ino && dentry->d_parent != dentry)
atomic_inc(&p_ino->count);
ino->inode = inode;
dir->i_nlink++;
inc_nlink(dir);
dir->i_mtime = CURRENT_TIME;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int bfs_link(struct dentry * old, struct inode * dir, struct dentry * new
unlock_kernel();
return err;
}
inode->i_nlink++;
inc_nlink(inode);
inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
atomic_inc(&inode->i_count);
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cFYI(1, ("cifs_mkdir returned 0x%x", rc));
d_drop(direntry);
} else {
inode->i_nlink++;
inc_nlink(inode);
if (pTcon->ses->capabilities & CAP_UNIX)
rc = cifs_get_inode_info_unix(&newinode, full_path,
inode->i_sb,xid);
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
coda_dir_changed(dir_inode, 0);
atomic_inc(&inode->i_count);
d_instantiate(de, inode);
inode->i_nlink++;
inc_nlink(inode);

out:
unlock_kernel();
Expand Down
4 changes: 2 additions & 2 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int init_dir(struct inode * inode)
inode->i_fop = &configfs_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
return 0;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ static int create_dir(struct config_item * k, struct dentry * p,
if (!error) {
error = configfs_create(d, mode, init_dir);
if (!error) {
p->d_inode->i_nlink++;
inc_nlink(p->d_inode);
(d)->d_op = &configfs_dentry_ops;
} else {
struct configfs_dirent *sd = d->d_fsdata;
Expand Down
2 changes: 1 addition & 1 deletion fs/configfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
inode->i_op = &configfs_dir_inode_operations;
inode->i_fop = &configfs_dir_operations;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
} else {
pr_debug("configfs: could not get root inode\n");
return -ENOMEM;
Expand Down
4 changes: 2 additions & 2 deletions fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
break;
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
res = debugfs_mknod(dir, dentry, mode, 0);
if (!res)
dir->i_nlink++;
inc_nlink(dir);
return res;
}

Expand Down
6 changes: 3 additions & 3 deletions fs/ext3/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ static int ext3_delete_entry (handle_t *handle,
*/
static inline void ext3_inc_count(handle_t *handle, struct inode *inode)
{
inode->i_nlink++;
inc_nlink(inode);
}

static inline void ext3_dec_count(handle_t *handle, struct inode *inode)
Expand Down Expand Up @@ -1775,7 +1775,7 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
iput (inode);
goto out_stop;
}
dir->i_nlink++;
inc_nlink(dir);
ext3_update_dx_flag(dir);
ext3_mark_inode_dirty(handle, dir);
d_instantiate(dentry, inode);
Expand Down Expand Up @@ -2341,7 +2341,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
if (new_inode) {
drop_nlink(new_inode);
} else {
new_dir->i_nlink++;
inc_nlink(new_dir);
ext3_update_dx_flag(new_dir);
ext3_mark_inode_dirty(handle, new_dir);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/fuse/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
return 0;

parent = fuse_control_sb->s_root;
parent->d_inode->i_nlink++;
inc_nlink(parent->d_inode);
sprintf(name, "%llu", (unsigned long long) fc->id);
parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2,
&simple_dir_inode_operations,
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
if (res)
return res;

inode->i_nlink++;
inc_nlink(inode);
hfsplus_instantiate(dst_dentry, inode, cnid);
atomic_inc(&inode->i_count);
inode->i_ctime = CURRENT_TIME_SEC;
Expand Down
4 changes: 2 additions & 2 deletions fs/hpfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
brelse(bh);
hpfs_mark_4buffers_dirty(&qbh0);
hpfs_brelse4(&qbh0);
dir->i_nlink++;
inc_nlink(dir);
insert_inode_hash(result);

if (result->i_uid != current->fsuid ||
Expand Down Expand Up @@ -635,7 +635,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
end:
hpfs_i(i)->i_parent_dir = new_dir->i_ino;
if (S_ISDIR(i->i_mode)) {
new_dir->i_nlink++;
inc_nlink(new_dir);
drop_nlink(old_dir);
}
if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) {
Expand Down
4 changes: 2 additions & 2 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
break;
case S_IFLNK:
inode->i_op = &page_symlink_inode_operations;
Expand Down Expand Up @@ -418,7 +418,7 @@ static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0);
if (!retval)
dir->i_nlink++;
inc_nlink(dir);
return retval;
}

Expand Down
6 changes: 3 additions & 3 deletions fs/jffs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
}

dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
dir_i->i_nlink++;
inc_nlink(dir_i);

jffs2_free_raw_dirent(rd);

Expand Down Expand Up @@ -836,7 +836,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
/* If it was a directory we moved, and there was no victim,
increase i_nlink on its new parent */
if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f)
new_dir_i->i_nlink++;
inc_nlink(new_dir_i);

/* Unlink the original */
ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
Expand All @@ -848,7 +848,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
/* Oh shit. We really ought to make a single node which can do both atomically */
struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode);
down(&f->sem);
old_dentry->d_inode->i_nlink++;
inc_nlink(old_dentry->d_inode);
if (f->inocache)
f->inocache->nlink++;
up(&f->sem);
Expand Down
6 changes: 3 additions & 3 deletions fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ void jffs2_read_inode (struct inode *inode)

for (fd=f->dents; fd; fd = fd->next) {
if (fd->type == DT_DIR && fd->ino)
inode->i_nlink++;
inc_nlink(inode);
}
/* and '..' */
inode->i_nlink++;
inc_nlink(inode);
/* Root dir gets i_nlink 3 for some reason */
if (inode->i_ino == 1)
inode->i_nlink++;
inc_nlink(inode);

inode->i_op = &jffs2_dir_inode_operations;
inode->i_fop = &jffs2_dir_operations;
Expand Down
6 changes: 3 additions & 3 deletions fs/jfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
mark_inode_dirty(ip);

/* update parent directory inode */
dip->i_nlink++; /* for '..' from child directory */
inc_nlink(dip); /* for '..' from child directory */
dip->i_ctime = dip->i_mtime = CURRENT_TIME;
mark_inode_dirty(dip);

Expand Down Expand Up @@ -822,7 +822,7 @@ static int jfs_link(struct dentry *old_dentry,
goto free_dname;

/* update object inode */
ip->i_nlink++; /* for new link */
inc_nlink(ip); /* for new link */
ip->i_ctime = CURRENT_TIME;
dir->i_ctime = dir->i_mtime = CURRENT_TIME;
mark_inode_dirty(dir);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto out4;
}
if (S_ISDIR(old_ip->i_mode))
new_dir->i_nlink++;
inc_nlink(new_dir);
}
/*
* Remove old directory entry
Expand Down
4 changes: 2 additions & 2 deletions fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
struct inode *inode = old_dentry->d_inode;

inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
inode->i_nlink++;
inc_nlink(inode);
atomic_inc(&inode->i_count);
dget(dentry);
d_instantiate(dentry, inode);
Expand Down Expand Up @@ -306,7 +306,7 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
drop_nlink(old_dir);
} else if (they_are_dirs) {
drop_nlink(old_dir);
new_dir->i_nlink++;
inc_nlink(new_dir);
}

old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
Expand Down
4 changes: 2 additions & 2 deletions fs/msdos/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode)
err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo);
if (err)
goto out_free;
dir->i_nlink++;
inc_nlink(dir);

inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
brelse(sinfo.bh);
Expand Down Expand Up @@ -551,7 +551,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
}
drop_nlink(old_dir);
if (!new_inode)
new_dir->i_nlink++;
inc_nlink(new_dir);
}

err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */
Expand Down
6 changes: 3 additions & 3 deletions fs/ocfs2/dlm/dlmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
inode->i_blocks = 0;
inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_nlink++;
inc_nlink(inode);

inode->i_fop = &simple_dir_operations;
inode->i_op = &dlmfs_root_inode_operations;
Expand Down Expand Up @@ -395,7 +395,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,

/* directory inodes start off with i_nlink ==
* 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
break;
}

Expand Down Expand Up @@ -449,7 +449,7 @@ static int dlmfs_mkdir(struct inode * dir,
}
ip->ip_dlm = dlm;

dir->i_nlink++;
inc_nlink(dir);
d_instantiate(dentry, inode);
dget(dentry); /* Extra count - pin the dentry in core */

Expand Down
8 changes: 4 additions & 4 deletions fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static int ocfs2_mknod(struct inode *dir,
mlog_errno(status);
goto leave;
}
dir->i_nlink++;
inc_nlink(dir);
}

status = ocfs2_add_entry(handle, dentry, inode,
Expand Down Expand Up @@ -730,7 +730,7 @@ static int ocfs2_link(struct dentry *old_dentry,
goto bail;
}

inode->i_nlink++;
inc_nlink(inode);
inode->i_ctime = CURRENT_TIME;
fe->i_links_count = cpu_to_le16(inode->i_nlink);
fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
Expand Down Expand Up @@ -952,7 +952,7 @@ static int ocfs2_unlink(struct inode *dir,
parent_node_bh);
if (status < 0) {
mlog_errno(status);
dir->i_nlink++;
inc_nlink(dir);
}
}

Expand Down Expand Up @@ -1382,7 +1382,7 @@ static int ocfs2_rename(struct inode *old_dir,
if (new_inode) {
new_inode->i_nlink--;
} else {
new_dir->i_nlink++;
inc_nlink(new_dir);
mark_inode_dirty(new_dir);
}
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_nlink++;
inc_nlink(inode);
break;
case S_IFLNK:
inode->i_op = &page_symlink_inode_operations;
Expand Down Expand Up @@ -113,7 +113,7 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
{
int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0);
if (!retval)
dir->i_nlink++;
inc_nlink(dir);
return retval;
}

Expand Down
Loading

0 comments on commit d8c76e6

Please sign in to comment.