Pārlūkot izejas kodu

nilfs2: missing a read lock for segment writer in nilfs_attach_checkpoint()

'ns_cno' of structure 'the_nilfs' must be protected from segment
writer, in other words, the caller of nilfs_get_checkpoint should hold
read lock for nilfs->ns_segctor_sem.  This patch adds the lock/unlock
operations in nilfs_attach_checkpoint() when calling
nilfs_cpfile_get_checkpoint().

Signed-off-by: Zhang Qiang <zhangqiang.buaa@gmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Zhang Qiang 16 gadi atpakaļ
vecāks
revīzija
1154ecbd2f
1 mainītis faili ar 2 papildinājumiem un 0 dzēšanām
  1. 2 0
      fs/nilfs2/super.c

+ 2 - 0
fs/nilfs2/super.c

@@ -416,8 +416,10 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
 	if (unlikely(err))
 	if (unlikely(err))
 		goto failed;
 		goto failed;
 
 
+	down_read(&nilfs->ns_segctor_sem);
 	err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
 	err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
 					  &bh_cp);
 					  &bh_cp);
+	up_read(&nilfs->ns_segctor_sem);
 	if (unlikely(err)) {
 	if (unlikely(err)) {
 		if (err == -ENOENT || err == -EINVAL) {
 		if (err == -ENOENT || err == -EINVAL) {
 			printk(KERN_ERR
 			printk(KERN_ERR