Skip to contentSkip to conversation

drivers/dax/super: Add annotation for ops in struct dax_device

PATCH In review Huaisheng Ye 3 participants 7 messages Jul 1, 2018 – Jul 2, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drivers/dax/super: Add annotation for ops in struct dax_device

From: Huaisheng Ye <[email protected]>

There is no annotation for member ops within struct dax_device. Add it.

---
 drivers/dax/super.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dax/super.c +1 -0
index 2b2332b..aa6382a 100644
@@ -161,6 +161,7 @@ enum dax_device_flags {
  * @host: optional name for lookups where the device path is not available
  * @private: dax driver private data
  * @flags: state and boolean properties
+ * @ops: function pointers for direct_access and fs-dax
  */
 struct dax_device {
 	struct hlist_node list;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/3 fs/ext2/inode: Fix a type cast error for fsdax

From: Huaisheng Ye <[email protected]>

The type of offset within struct iomap is loff_t, which represents file offset of mapping.

In ext2_iomap_begin, iomap->offset shall be given a type cast as loff_t instead of u64.

---
 fs/ext2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/inode.c +1 -1
index 7163590..ca211bd 100644
@@ -816,7 +816,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 
 	iomap->flags = 0;
 	iomap->bdev = inode->i_sb->s_bdev;
-	iomap->offset = (u64)first_block << blkbits;
+	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
 	if (ret == 0) {
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax

Quoted 7 lines · Huaisheng Ye

From: Huaisheng Ye <[email protected]>

The type of offset within struct iomap is loff_t, which represents file offset of mapping.

In ext2_iomap_begin, iomap->offset shall be given a type cast as loff_t instead of u64.

Why is it an error? loff_t is uniformly typedefed to long long. In which case the second variant is different from the first one *and* does not step into nasal demon territory?

Quoted 2 lines
fs/ext2/inode.c +1 -1
-	iomap->offset = (u64)first_block << blkbits;
+	iomap->offset = (loff_t)first_block << blkbits;
#3 lore raw

Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax

---- On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro <[email protected]> wrote ----

Quoted 6 lines · Huaisheng Ye
Quoted 5 lines

From: Huaisheng Ye <[email protected]>

The type of offset within struct iomap is loff_t, which represents file offset of mapping.

Quoted 6 lines
Quoted 2 lines

In ext2_iomap_begin, iomap->offset shall be given a type cast as loff_t instead of u64.

Why is it an error? loff_t is uniformly typedefed to long long. In which case the second variant is different from the first one *and* does not step into nasal demon territory?

Sorry for my inaccuracy.
The type of iomap->offset is loff_t, is it better to cast first_block to loff_t, then do the left shift operation?

Quoted 4 lines

fs/ext2/inode.c static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, · line 819

Quoted 3 lines
fs/ext2/inode.c +1 -1
-    iomap->offset = (u64)first_block << blkbits; 
+    iomap->offset = (loff_t)first_block << blkbits; 

---
Cheers,
Huaisheng

#4 lore raw

Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax

Quoted 10 lines · Huaisheng Ye

---- On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro <[email protected]> wrote ----

Quoted 9 lines · Huaisheng Ye
Quoted 7 lines

From: Huaisheng Ye <[email protected]>

The type of offset within struct iomap is loff_t, which represents file offset of mapping.

In ext2_iomap_begin, iomap->offset shall be given a type cast as loff_t instead of u64.

Quoted 7 lines
Quoted 3 lines

Why is it an error? loff_t is uniformly typedefed to long long. In which case the second variant is different from the first one *and* does not step into nasal demon territory?

Sorry for my inaccuracy.
The type of iomap->offset is loff_t, is it better to cast first_block to loff_t, then do the left shift operation?

I think what Al meant is that in the kernel loff_t is 64-bit anyway and furthermore it is signed which means most people have to look up C standard to remember how right shift is (un)defined if it would overflow ;). So this does not really make the code any more readable. Rather on contrary...

Honza

Quoted 11 lines
Quoted 5 lines

fs/ext2/inode.c static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, · line 819

Quoted 4 lines
fs/ext2/inode.c +1 -1
-    iomap->offset = (u64)first_block << blkbits; 
+    iomap->offset = (loff_t)first_block << blkbits; 

---
Cheers,
Huaisheng

Signature · 2 lines
Jan Kara <jack-IBi9RG/[email protected]>
SUSE Labs, CR
#5 lore raw

PATCH 3/3 fs/ext2/inode: Optimize the condition for iomap_begin

In reply to Huaisheng Ye

From: Huaisheng Ye <[email protected]>

If ext2_get_blocks returns negative result, ext2_iomap_begin will return for error case.
Adjust the judging condition of ret value will be useful for code simplification.

---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/ext2/inode.c +5 -5
index ca211bd..9b1004d 100644
@@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin

Quoted 8 lines · Huaisheng Ye

From: Huaisheng Ye <[email protected]>

If ext2_get_blocks returns negative result, ext2_iomap_begin will return for error case.
Adjust the judging condition of ret value will be useful for code simplification.

I'm sorry but how exactly is this simpler?

Honza

Quoted 34 lines
---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/ext2/inode.c +5 -5
index ca211bd..9b1004d 100644
@@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)
Signature · 1 line
1.8.3.1
Signature · 2 lines
Jan Kara <jack-IBi9RG/[email protected]>
SUSE Labs, CR