Skip to contentSkip to conversation

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

PATCH In review Zhang Qiang 2 participants 2 messages Aug 18, 2009 1 message not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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_check_point 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().

---
 fs/nilfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nilfs2/super.c +2 -0
index 05174c5..55f3d6b 100644
@@ -371,8 +371,10 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
 	if (unlikely(err))
 		goto failed;
 
+	down_read(&nilfs->ns_segctor_sem);
 	err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
 					  &bh_cp);
+	up_read(&nilfs->ns_segctor_sem);
 	if (unlikely(err)) {
 		if (err == -ENOENT || err == -EINVAL) {
 			printk(KERN_ERR
Signature · 1 line
1.6.0.6

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi,

Quoted 28 lines · Zhang Qiang

'ns_cno' of structure 'the_nilfs' must be protected from segment writer, in other words, the caller of nilfs_get_check_point 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().

---
 fs/nilfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nilfs2/super.c +2 -0
index 05174c5..55f3d6b 100644
@@ -371,8 +371,10 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
 	if (unlikely(err))
 		goto failed;
 
+	down_read(&nilfs->ns_segctor_sem);
 	err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
 					  &bh_cp);
+	up_read(&nilfs->ns_segctor_sem);
 	if (unlikely(err)) {
 		if (err == -ENOENT || err == -EINVAL) {
 			printk(KERN_ERR
Signature · 1 line
1.6.0.6

Yeah, this is necessary.

Will be applied. Thank you.

Ryusuke Konishi