mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
blkid: simplify fs block size check
Only the LV path name is needed for blkid query, the step of getting a dev struct is not needed.
This commit is contained in:
parent
71933d3496
commit
318bb3a06b
@ -701,23 +701,23 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BLKID_WIPING_SUPPORT
|
#ifdef BLKID_WIPING_SUPPORT
|
||||||
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
int get_fs_block_size(const char *pathname, uint32_t *fs_block_size)
|
||||||
{
|
{
|
||||||
char *block_size_str = NULL;
|
char *block_size_str = NULL;
|
||||||
|
|
||||||
if ((block_size_str = blkid_get_tag_value(NULL, "BLOCK_SIZE", dev_name(dev)))) {
|
if ((block_size_str = blkid_get_tag_value(NULL, "BLOCK_SIZE", pathname))) {
|
||||||
*fs_block_size = (uint32_t)atoi(block_size_str);
|
*fs_block_size = (uint32_t)atoi(block_size_str);
|
||||||
free(block_size_str);
|
free(block_size_str);
|
||||||
log_debug("Found blkid BLOCK_SIZE %u for fs on %s", *fs_block_size, dev_name(dev));
|
log_debug("Found blkid BLOCK_SIZE %u for fs on %s", *fs_block_size, pathname);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
log_debug("No blkid BLOCK_SIZE for fs on %s", dev_name(dev));
|
log_debug("No blkid BLOCK_SIZE for fs on %s", pathname);
|
||||||
*fs_block_size = 0;
|
*fs_block_size = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
int get_fs_block_size(const char *pathname, uint32_t *fs_block_size)
|
||||||
{
|
{
|
||||||
log_debug("Disabled blkid BLOCK_SIZE for fs.");
|
log_debug("Disabled blkid BLOCK_SIZE for fs.");
|
||||||
*fs_block_size = 0;
|
*fs_block_size = 0;
|
||||||
|
@ -100,6 +100,6 @@ int dev_is_nvme(struct dev_types *dt, struct device *dev);
|
|||||||
|
|
||||||
int dev_is_lv(struct device *dev);
|
int dev_is_lv(struct device *dev);
|
||||||
|
|
||||||
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size);
|
int get_fs_block_size(const char *pathname, uint32_t *fs_block_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -326,7 +326,6 @@ static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_vol
|
|||||||
int lbs_4k, int lbs_512, int pbs_4k, int pbs_512)
|
int lbs_4k, int lbs_512, int pbs_4k, int pbs_512)
|
||||||
{
|
{
|
||||||
char pathname[PATH_MAX];
|
char pathname[PATH_MAX];
|
||||||
struct device *fs_dev;
|
|
||||||
uint32_t fs_block_size = 0;
|
uint32_t fs_block_size = 0;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
@ -371,10 +370,6 @@ static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_vol
|
|||||||
log_error("Path name too long to get LV block size %s", display_lvname(lv));
|
log_error("Path name too long to get LV block size %s", display_lvname(lv));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (!(fs_dev = dev_cache_get(cmd, pathname, NULL))) {
|
|
||||||
log_error("Device for LV not found to check block size %s", display_lvname(lv));
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_fs_block_size() returns the libblkid BLOCK_SIZE value,
|
* get_fs_block_size() returns the libblkid BLOCK_SIZE value,
|
||||||
@ -387,7 +382,7 @@ static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_vol
|
|||||||
* value the block size, but it's possible values are not the same
|
* value the block size, but it's possible values are not the same
|
||||||
* as xfs's, and do not seem to relate directly to the device LBS.
|
* as xfs's, and do not seem to relate directly to the device LBS.
|
||||||
*/
|
*/
|
||||||
rv = get_fs_block_size(fs_dev, &fs_block_size);
|
rv = get_fs_block_size(pathname, &fs_block_size);
|
||||||
if (!rv || !fs_block_size) {
|
if (!rv || !fs_block_size) {
|
||||||
int use_bs;
|
int use_bs;
|
||||||
|
|
||||||
|
@ -5948,7 +5948,6 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
|
|||||||
uint32_t *block_size_sectors)
|
uint32_t *block_size_sectors)
|
||||||
{
|
{
|
||||||
char pathname[PATH_MAX];
|
char pathname[PATH_MAX];
|
||||||
struct device *fs_dev;
|
|
||||||
struct dm_list pvs_list;
|
struct dm_list pvs_list;
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
uint32_t fs_block_size = 0;
|
uint32_t fs_block_size = 0;
|
||||||
@ -6011,18 +6010,11 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sync_local_dev_names(cmd))
|
|
||||||
stack;
|
|
||||||
|
|
||||||
if (!(fs_dev = dev_cache_get(cmd, pathname, NULL))) {
|
|
||||||
if (test_mode()) {
|
if (test_mode()) {
|
||||||
log_print("Test mode skips checking fs block size.");
|
log_print("Test mode skips checking fs block size.");
|
||||||
fs_block_size = 0;
|
fs_block_size = 0;
|
||||||
goto skip_fs;
|
goto skip_fs;
|
||||||
}
|
}
|
||||||
log_error("Device for LV not found to check block size %s", pathname);
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_fs_block_size() returns the libblkid BLOCK_SIZE value,
|
* get_fs_block_size() returns the libblkid BLOCK_SIZE value,
|
||||||
@ -6037,7 +6029,7 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
|
|||||||
*
|
*
|
||||||
* With 512 LBS and 4K PBS, mkfs.xfs will use xfs sector size 4K.
|
* With 512 LBS and 4K PBS, mkfs.xfs will use xfs sector size 4K.
|
||||||
*/
|
*/
|
||||||
rv = get_fs_block_size(fs_dev, &fs_block_size);
|
rv = get_fs_block_size(pathname, &fs_block_size);
|
||||||
skip_fs:
|
skip_fs:
|
||||||
if (!rv || !fs_block_size) {
|
if (!rv || !fs_block_size) {
|
||||||
if (lbs_4k && pbs_4k && !pbs_512) {
|
if (lbs_4k && pbs_4k && !pbs_512) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user