nilfs2: add reader's lock for cno in nilfs_ioctl_sync
authorJiro SEKIBA <jir@unicus.jp>
Sat, 20 Feb 2010 10:47:49 +0000 (19:47 +0900)
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Sat, 20 Feb 2010 12:18:19 +0000 (21:18 +0900)
This adds reader's lock for the_nilfs->cno in nilfs_ioctl_sync,
for the_nilfs->cno should be proctected by segctor_sem when reading.

Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
fs/nilfs2/ioctl.c

index 8e5cad020c3096ca45965ca2a264e4e770554c31..313d0a21da480afc05afacfb46bec6f74e34b76a 100644 (file)
@@ -601,13 +601,17 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
 {
        __u64 cno;
        int ret;
+       struct the_nilfs *nilfs;
 
        ret = nilfs_construct_segment(inode->i_sb);
        if (ret < 0)
                return ret;
 
        if (argp != NULL) {
-               cno = NILFS_SB(inode->i_sb)->s_nilfs->ns_cno - 1;
+               nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
+               down_read(&nilfs->ns_segctor_sem);
+               cno = nilfs->ns_cno - 1;
+               up_read(&nilfs->ns_segctor_sem);
                if (copy_to_user(argp, &cno, sizeof(cno)))
                        return -EFAULT;
        }