Skip to contentSkip to conversation

device-dax: delete a redundancy check in dev_dax_validate_align()

PATCH In review Zhen Lei 2 participants 3 messages Nov 20, 2020 – Dec 17, 2020

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 device-dax: delete a redundancy check in dev_dax_validate_align()

After we have done the alignment check for the length of each range, the alignment check for dev_dax_size(dev_dax) is no longer needed, because it get the sum of the length of each range.

---
 drivers/dax/bus.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/dax/bus.c +0 -7
index 1efae11d947a..35f9238c0139 100644
@@ -1109,16 +1109,9 @@ static ssize_t align_show(struct device *dev,
 
 static ssize_t dev_dax_validate_align(struct dev_dax *dev_dax)
 {
-	resource_size_t dev_size = dev_dax_size(dev_dax);
 	struct device *dev = &dev_dax->dev;
 	int i;
 
-	if (dev_size > 0 && !alloc_is_aligned(dev_dax, dev_size)) {
-		dev_dbg(dev, "%s: align %u invalid for size %pa\n",
-			__func__, dev_dax->align, &dev_size);
-		return -EINVAL;
-	}
-
 	for (i = 0; i < dev_dax->nr_range; i++) {
 		size_t len = range_len(&dev_dax->ranges[i].range);
 
Signature · 5 lines
2.26.0.106.g9fadedd

_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#1 lore raw
Quoted 3 lines · Zhen Lei

After we have done the alignment check for the length of each range, the alignment check for dev_dax_size(dev_dax) is no longer needed, because it get the sum of the length of each range.

For example:
x/M + y/M = (x + y)/M
If x/M is a integer and y/M is also a integer, then (x + y)/M must be a integer.

Quoted 18 lines
---
 drivers/dax/bus.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/dax/bus.c +0 -1
index 1efae11d947a..35f9238c0139 100644
@@ -1109,16 +1109,9 @@ static ssize_t align_show(struct device *dev,
 
 static ssize_t dev_dax_validate_align(struct dev_dax *dev_dax)
 {
-	resource_size_t dev_size = dev_dax_size(dev_dax);
 	struct device *dev = &dev_dax->dev;
 	int i;

drivers/dax/bus.c static ssize_t align_show(struct device *dev, · line 1117

Quoted 10 lines
drivers/dax/bus.c +0 -6
 
-	if (dev_size > 0 && !alloc_is_aligned(dev_dax, dev_size)) {
-		dev_dbg(dev, "%s: align %u invalid for size %pa\n",
-			__func__, dev_dax->align, &dev_size);
-		return -EINVAL;
-	}
-
 	for (i = 0; i < dev_dax->nr_range; i++) {
 		size_t len = range_len(&dev_dax->ranges[i].range);
 

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#2 lore raw
Quoted 12 lines · Leizhen (ThunderTown)
Quoted 3 lines · Zhen Lei

After we have done the alignment check for the length of each range, the alignment check for dev_dax_size(dev_dax) is no longer needed, because it get the sum of the length of each range.

For example:
x/M + y/M = (x + y)/M
If x/M is a integer and y/M is also a integer, then (x + y)/M must be a integer.

True... I was going to say that the different error messages might be useful, but those are debug statements anyways, so I'll apply this.
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]