Skip to contentSkip to conversation

master - devices: clean up block size functions

PATCH David Teigland 1 participant 1 message Aug 7, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=09bc2d0fd15a5bbb5d1e8d6ce79bd786ffed42b3
Commit:        09bc2d0fd15a5bbb5d1e8d6ce79bd786ffed42b3
Parent:        bec3088f85a9a2d0b6a355aea1adc67fab8de6e9
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Aug 7 11:38:06 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Aug 7 11:48:10 2019 -0500

devices: clean up block size functions

Replace calls to the old dev_get_block_size function with calls to the new dev_get_direct_block_size function, and remove the old function.

---
 lib/device/dev-cache.c  |    2 -
 lib/device/dev-io.c     |   73 -----------------------------------------------
 lib/device/device.h     |    3 --
 lib/locking/lvmlockd.c  |   10 +++---
 lib/metadata/metadata.c |   25 ++++++++--------
 5 files changed, 18 insertions(+), 95 deletions(-)
lib/device/dev-cache.c +0 -2
index 980dd3c..a15e239 100644
@@ -64,8 +64,6 @@ static int _insert(const char *path, const struct stat *info,
 /* Setup non-zero members of passed zeroed 'struct device' */
 static void _dev_init(struct device *dev)
 {
-	dev->phys_block_size = -1;
-	dev->block_size = -1;
 	dev->fd = -1;
 	dev->read_ahead = -1;
 
lib/device/dev-io.c +0 -73

85 lines not on this page · raw message

lib/device/device.h +0 -3
index bb65f84..bd3b355 100644
@@ -67,8 +67,6 @@ struct device {
 	/* private */
 	int fd;
 	int open_count;
-	int phys_block_size;     /* From either BLKPBSZGET or BLKSSZGET, don't use */
-	int block_size;	         /* From BLKBSZGET, returns bdev->bd_block_size, likely set by fs, probably don't use */
 	int physical_block_size; /* From BLKPBSZGET: lowest possible sector size that the hardware can operate on without reverting to read-modify-write operations */
 	int logical_block_size;  /* From BLKSSZGET: lowest possible block size that the storage device can address */
 	int read_ahead;
@@ -133,7 +131,6 @@ void dev_size_seqno_inc(void);
 /*
  * All io should use these routines.
  */
-int dev_get_block_size(struct device *dev, unsigned int *phys_block_size, unsigned int *block_size);
 int dev_get_direct_block_sizes(struct device *dev, unsigned int *physical_block_size,
                                unsigned int *logical_block_size);
 int dev_get_size(struct device *dev, uint64_t *size);
lib/locking/lvmlockd.c +5 -5
index 5ef3c94..612de5d 100644
@@ -636,7 +636,7 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in
 	struct pv_list *pvl;
 	struct device *sector_dev;
 	uint32_t sector_size = 0;
-	unsigned int phys_block_size, block_size;
+	unsigned int physical_block_size, logical_block_size;
 	int num_mb = 0;
 	int result;
 	int ret;
@@ -653,14 +653,14 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in
 	 */
 
 	dm_list_iterate_items(pvl, &vg->pvs) {
-		if (!dev_get_block_size(pvl->pv->dev, &phys_block_size, &block_size))
+		if (!dev_get_direct_block_sizes(pvl->pv->dev, &physical_block_size, &logical_block_size))
 			continue;
 
 		if (!sector_size) {
-			sector_size = phys_block_size;
+			sector_size = logical_block_size;
 			sector_dev = pvl->pv->dev;
-		} else if (sector_size != phys_block_size) {
-			log_error("Inconsistent sector sizes for %s and %s.",
+		} else if (sector_size != logical_block_size) {
+			log_error("Inconsistent logical block sizes for %s and %s.",
 				  dev_name(pvl->pv->dev), dev_name(sector_dev));
 			return 0;
 		}
lib/metadata/metadata.c +13 -12
index e55adc2..0f5154d 100644
@@ -679,20 +679,21 @@ int vg_remove(struct volume_group *vg)
 }
 
 int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *vg,
-				unsigned int *max_phys_block_size_found)
+				unsigned int *max_logical_block_size_found)
 {
-	unsigned int phys_block_size, block_size;
+	unsigned int physical_block_size, logical_block_size;
 
-	if (!(dev_get_block_size(dev, &phys_block_size, &block_size)))
+	if (!(dev_get_direct_block_sizes(dev, &physical_block_size, &logical_block_size)))
 		return_0;
 
-	if (phys_block_size > *max_phys_block_size_found)
-		*max_phys_block_size_found = phys_block_size;
+	/* FIXME: max_logical_block_size_found does not seem to be used anywhere */
+	if (logical_block_size > *max_logical_block_size_found)
+		*max_logical_block_size_found = logical_block_size;
 
-	if (phys_block_size >> SECTOR_SHIFT > vg->extent_size) {
+	if (logical_block_size >> SECTOR_SHIFT > vg->extent_size) {
 		log_error("Physical extent size used for volume group %s "
-			  "is less than physical block size that %s uses.",
-			   vg->name, dev_name(dev));
+			  "is less than logical block size (%u bytes) that %s uses.",
+			   vg->name, logical_block_size, dev_name(dev));
 		return 0;
 	}
 
@@ -702,10 +703,10 @@ int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *v
 int vg_check_pv_dev_block_sizes(const struct volume_group *vg)
 {
 	struct pv_list *pvl;
-	unsigned int max_phys_block_size_found = 0;
+	unsigned int max_logical_block_size_found = 0;
 
 	dm_list_iterate_items(pvl, &vg->pvs) {
-		if (!check_dev_block_size_for_vg(pvl->pv->dev, vg, &max_phys_block_size_found))
+		if (!check_dev_block_size_for_vg(pvl->pv->dev, vg, &max_logical_block_size_found))
 			return 0;
 	}
 
@@ -750,7 +751,7 @@ int check_pv_dev_sizes(struct volume_group *vg)
 int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
 {
 	struct pv_list *pvl;
-	unsigned int max_phys_block_size = 0;
+	unsigned int max_logical_block_size = 0;
 	unsigned int physical_block_size, logical_block_size;
 	unsigned int prev_lbs = 0;
 	int inconsistent_existing_lbs = 0;
@@ -790,7 +791,7 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
 
 		if (!(check_dev_block_size_for_vg(pvl->pv->dev,
 						  (const struct volume_group *) vg,
-						  &max_phys_block_size))) {
+						  &max_logical_block_size))) {
 			log_error("PV %s has wrong block size.", pv_dev_name(pvl->pv));
 			return 0;
 		}