Skip to contentSkip to conversation

nilfs2: trivial coding style fix

PATCH In review Jiro SEKIBA 3 participants 6 messages Dec 4, 2009 – Dec 7, 2009 4 messages not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nilfs2: trivial coding style fix

Hi,

This is a trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |    5 +++--
 fs/nilfs2/direct.c |   14 ++++++++------
 3 files changed, 13 insertions(+), 9 deletions(-)
fs/nilfs2/bmap.c +2 -1
index 08834df..78ccbba 100644
@@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page, key++)
+		;
 
 	return key;
 }
fs/nilfs2/cpfile.c +3 -2
index 3f5d5d0..a86d402 100644
@@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
+			count = nilfs_cpfile_block_sub_valid_checkpoints(
+				  cpfile, cp_bh, kaddr, nicps);
 			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
+			    count == 0) {
 				/* make hole */
 				kunmap_atomic(kaddr, KM_USER0);
 				brelse(cp_bh);
fs/nilfs2/direct.c +8 -6
index d369ac7..f817282 100644
@@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 
 	direct = (struct nilfs_direct *)bmap;
 	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	    (level != 1))  /* XXX: use macro for level 1 */
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5

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

#2 lore raw

Hi,

Quoted 11 lines · Jiro SEKIBA

Hi,

This is a trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |    5 +++--
 fs/nilfs2/direct.c |   14 ++++++++------
 3 files changed, 13 insertions(+), 9 deletions(-)

Ok, I'll comment inline below.

fs/nilfs2/bmap.c __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, · line 430

Quoted 11 lines
fs/nilfs2/bmap.c +2 -1
index 08834df..78ccbba 100644
@@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page, key++)
+		;

How about moving the "key++" inside the loop? The line break in the middle of the for-sentence looks eliminable.

Quoted 7 lines
fs/nilfs2/bmap.c +0 -0
 	return key;
 }
fs/nilfs2/cpfile.c +0 -0
index 3f5d5d0..a86d402 100644

fs/nilfs2/cpfile.c int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, · line 334

Quoted 9 lines
fs/nilfs2/cpfile.c +3 -2
@@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
+			count = nilfs_cpfile_block_sub_valid_checkpoints(
+				  cpfile, cp_bh, kaddr, nicps);
 			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
+			    count == 0) {

This conversion is not equivalent because nilfs_cpfile_block_sub_valid_checkpoints() has a side effect.

Quoted 9 lines
fs/nilfs2/cpfile.c +0 -0
 				/* make hole */
 				kunmap_atomic(kaddr, KM_USER0);
 				brelse(cp_bh);
fs/nilfs2/direct.c +0 -0
index d369ac7..f817282 100644
@@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 

fs/nilfs2/direct.c static int nilfs_direct_lookup(const struct nilfs_bmap *bmap, · line 60

Quoted 10 lines
fs/nilfs2/direct.c +4 -3
 	direct = (struct nilfs_direct *)bmap;
 	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	    (level != 1))  /* XXX: use macro for level 1 */
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;

Looks good, but it's still redundant. How about removing unnecessary parentheses in this occasion?

The first conditional statement can be simplified to:

	if (key > NILFS_DIRECT_KEY_MAX || level != 1)

fs/nilfs2/direct.c static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap, · line 81

Quoted 13 lines
fs/nilfs2/direct.c +4 -3
 	if (ptrp != NULL)
@@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;

Looks good to me.

Quoted 3 lines
fs/nilfs2/direct.c +0 -0
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5

Thanks,
Ryusuke Konishi

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

#4 lore raw

Hi,

Thank you for the reveiew.
I'll revise the patch!

thanks

regards,

At Fri, 04 Dec 2009 20:01:02 +0900 (JST),

Quoted 109 lines · Ryusuke Konishi

Hi,

Quoted 11 lines · Jiro SEKIBA

Hi,

This is a trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |    5 +++--
 fs/nilfs2/direct.c |   14 ++++++++------
 3 files changed, 13 insertions(+), 9 deletions(-)

Ok, I'll comment inline below.

fs/nilfs2/bmap.c __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, · line 430

Quoted 11 lines
fs/nilfs2/bmap.c +2 -1
index 08834df..78ccbba 100644
@@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page, key++)
+		;

How about moving the "key++" inside the loop? The line break in the middle of the for-sentence looks eliminable.

Quoted 7 lines
fs/nilfs2/bmap.c +0 -0
 	return key;
 }
fs/nilfs2/cpfile.c +0 -0
index 3f5d5d0..a86d402 100644

fs/nilfs2/cpfile.c int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, · line 334

Quoted 9 lines
fs/nilfs2/cpfile.c +3 -2
@@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
+			count = nilfs_cpfile_block_sub_valid_checkpoints(
+				  cpfile, cp_bh, kaddr, nicps);
 			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
+			    count == 0) {

This conversion is not equivalent because nilfs_cpfile_block_sub_valid_checkpoints() has a side effect.

Quoted 9 lines
fs/nilfs2/cpfile.c +0 -0
 				/* make hole */
 				kunmap_atomic(kaddr, KM_USER0);
 				brelse(cp_bh);
fs/nilfs2/direct.c +0 -0
index d369ac7..f817282 100644
@@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 

fs/nilfs2/direct.c static int nilfs_direct_lookup(const struct nilfs_bmap *bmap, · line 60

Quoted 10 lines
fs/nilfs2/direct.c +4 -3
 	direct = (struct nilfs_direct *)bmap;
 	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	    (level != 1))  /* XXX: use macro for level 1 */
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;

Looks good, but it's still redundant. How about removing unnecessary parentheses in this occasion?

The first conditional statement can be simplified to:

	if (key > NILFS_DIRECT_KEY_MAX || level != 1)

fs/nilfs2/direct.c static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap, · line 81

Quoted 13 lines
fs/nilfs2/direct.c +4 -3
 	if (ptrp != NULL)
@@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;

Looks good to me.

Quoted 3 lines
fs/nilfs2/direct.c +0 -0
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5

Thanks,
Ryusuke Konishi
_______________________________________________
users mailing list
[email protected]
https://www.nilfs.org/mailman/listinfo/users

Signature · 1 line
Jiro SEKIBA <[email protected]>
#5 lore raw

PATCH 1/1 nilfs2: trivial coding style fix

In reply to a message not in the archive

Hi,

This is a revised version of trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
 fs/nilfs2/direct.c |   17 +++++++++--------
 3 files changed, 29 insertions(+), 22 deletions(-)
fs/nilfs2/bmap.c +2 -1
index f4a14ea..88db45a 100644
@@ -418,7 +418,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page)
+		key++;
 
 	return key;
 }
fs/nilfs2/cpfile.c +18 -13
index d5ad54e..1873781 100644
@@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
-			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
-				/* make hole */
-				kunmap_atomic(kaddr, KM_USER0);
-				brelse(cp_bh);
-				ret = nilfs_cpfile_delete_checkpoint_block(
-					cpfile, cno);
-				if (ret == 0)
-					continue;
-				printk(KERN_ERR "%s: cannot delete block\n",
-				       __func__);
-				break;
+			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
+				count =
+				  nilfs_cpfile_block_sub_valid_checkpoints(
+						cpfile, cp_bh, kaddr, nicps);
+				if (count == 0) {
+					/* make hole */
+					kunmap_atomic(kaddr, KM_USER0);
+					brelse(cp_bh);
+					ret =
+					  nilfs_cpfile_delete_checkpoint_block(
+								   cpfile, cno);
+					if (ret == 0)
+						continue;
+					printk(KERN_ERR
+					       "%s: cannot delete block\n",
+					       __func__);
+					break;
+				}
 			}
 		}
 
fs/nilfs2/direct.c +9 -8
index d369ac7..31d51fc 100644
@@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 	struct nilfs_direct *direct;
 	__u64 ptr;
 
-	direct = (struct nilfs_direct *)bmap;
-	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
+	if ((key > NILFS_DIRECT_KEY_MAX) || (level != 1))
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5

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

#7 lore raw

Hi,

I re-read the comment and realized that there are some room to simplify the sytyle. This is a re-revised version.

This is a trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

---
 fs/nilfs2/bmap.c   |    4 ++--
 fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
 fs/nilfs2/direct.c |   17 +++++++++--------
 3 files changed, 29 insertions(+), 23 deletions(-)
fs/nilfs2/bmap.c +2 -2
index f4a14ea..effdbdb 100644
@@ -417,8 +417,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
-	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
+		key++;
 
 	return key;
 }
fs/nilfs2/cpfile.c +18 -13
index d5ad54e..1873781 100644
@@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
-			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
-				/* make hole */
-				kunmap_atomic(kaddr, KM_USER0);
-				brelse(cp_bh);
-				ret = nilfs_cpfile_delete_checkpoint_block(
-					cpfile, cno);
-				if (ret == 0)
-					continue;
-				printk(KERN_ERR "%s: cannot delete block\n",
-				       __func__);
-				break;
+			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
+				count =
+				  nilfs_cpfile_block_sub_valid_checkpoints(
+						cpfile, cp_bh, kaddr, nicps);
+				if (count == 0) {
+					/* make hole */
+					kunmap_atomic(kaddr, KM_USER0);
+					brelse(cp_bh);
+					ret =
+					  nilfs_cpfile_delete_checkpoint_block(
+								   cpfile, cno);
+					if (ret == 0)
+						continue;
+					printk(KERN_ERR
+					       "%s: cannot delete block\n",
+					       __func__);
+					break;
+				}
 			}
 		}
 
fs/nilfs2/direct.c +9 -8
index d369ac7..236753d 100644
@@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 	struct nilfs_direct *direct;
 	__u64 ptr;
 
-	direct = (struct nilfs_direct *)bmap;
-	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
+	if (key > NILFS_DIRECT_KEY_MAX || level != 1)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5

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

#9 lore raw

Hi,

Quoted 8 lines · Jiro SEKIBA

Hi,

I re-read the comment and realized that there are some room to simplify the sytyle. This is a re-revised version.

This is a trivial style fix patch to mend errors/warnings reported by "checkpatch.pl --file".

Quoted 6 lines
---
 fs/nilfs2/bmap.c   |    4 ++--
 fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
 fs/nilfs2/direct.c |   17 +++++++++--------
 3 files changed, 29 insertions(+), 23 deletions(-)

Looks good. I'll queue it up.

Thanks,
Ryusuke Konishi

Quoted 94 lines
fs/nilfs2/bmap.c +2 -2
index f4a14ea..effdbdb 100644
@@ -417,8 +417,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
-	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
+		key++;
 
 	return key;
 }
fs/nilfs2/cpfile.c +18 -13
index d5ad54e..1873781 100644
@@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
-			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
-				/* make hole */
-				kunmap_atomic(kaddr, KM_USER0);
-				brelse(cp_bh);
-				ret = nilfs_cpfile_delete_checkpoint_block(
-					cpfile, cno);
-				if (ret == 0)
-					continue;
-				printk(KERN_ERR "%s: cannot delete block\n",
-				       __func__);
-				break;
+			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
+				count =
+				  nilfs_cpfile_block_sub_valid_checkpoints(
+						cpfile, cp_bh, kaddr, nicps);
+				if (count == 0) {
+					/* make hole */
+					kunmap_atomic(kaddr, KM_USER0);
+					brelse(cp_bh);
+					ret =
+					  nilfs_cpfile_delete_checkpoint_block(
+								   cpfile, cno);
+					if (ret == 0)
+						continue;
+					printk(KERN_ERR
+					       "%s: cannot delete block\n",
+					       __func__);
+					break;
+				}
 			}
 		}
 
fs/nilfs2/direct.c +9 -8
index d369ac7..236753d 100644
@@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 	struct nilfs_direct *direct;
 	__u64 ptr;
 
-	direct = (struct nilfs_direct *)bmap;
-	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
+	if (key > NILFS_DIRECT_KEY_MAX || level != 1)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
Signature · 1 line
1.5.6.5