Message ID | 20210604011844.1756145-9-ruansy.fnst@fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fsdax: introduce fs query to support reflink | expand |
Hi Shiyang, Thank you for the patch! Yet something to improve: [auto build test ERROR on xfs-linux/for-next] [also build test ERROR on dm/for-next linus/master v5.13-rc4] [cannot apply to hnaz-linux-mm/master next-20210603] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Shiyang-Ruan/fsdax-introduce-fs-query-to-support-reflink/20210604-092105 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next config: h8300-randconfig-r021-20210604 (attached as .config) compiler: h8300-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/94db8a17905296e4d5bfe93eb5199f477646622a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Shiyang-Ruan/fsdax-introduce-fs-query-to-support-reflink/20210604-092105 git checkout 94db8a17905296e4d5bfe93eb5199f477646622a # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All error/warnings (new ones prefixed by >>): drivers/md/dm.c: In function 'open_table_device': >> drivers/md/dm.c:784:12: error: implicit declaration of function 'dax_get_holder'; did you mean 'xa_get_order'? [-Werror=implicit-function-declaration] 784 | holders = dax_get_holder(td->dm_dev.dax_dev); | ^~~~~~~~~~~~~~ | xa_get_order >> drivers/md/dm.c:784:10: warning: assignment to 'struct list_head *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 784 | holders = dax_get_holder(td->dm_dev.dax_dev); | ^ >> drivers/md/dm.c:788:3: error: implicit declaration of function 'dax_set_holder'; did you mean 'xas_set_order'? [-Werror=implicit-function-declaration] 788 | dax_set_holder(td->dm_dev.dax_dev, holders, &dm_dax_holder_ops); | ^~~~~~~~~~~~~~ | xas_set_order drivers/md/dm.c: In function 'close_table_device': drivers/md/dm.c:808:10: warning: assignment to 'struct list_head *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 808 | holders = dax_get_holder(td->dm_dev.dax_dev); | ^ drivers/md/dm.c: In function 'dm_dax_corrputed_range': >> drivers/md/dm.c:1339:30: warning: initialization of 'struct list_head *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 1339 | struct list_head *holders = dax_get_holder(dax_dev); | ^~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +784 drivers/md/dm.c 750 751 static char *_dm_claim_ptr = "I belong to device-mapper"; 752 static const struct dax_holder_operations dm_dax_holder_ops; 753 struct dm_holder { 754 struct list_head list; 755 struct mapped_device *md; 756 }; 757 /* 758 * Open a table device so we can use it as a map destination. 759 */ 760 static int open_table_device(struct table_device *td, dev_t dev, 761 struct mapped_device *md) 762 { 763 struct block_device *bdev; 764 struct list_head *holders; 765 struct dm_holder *holder; 766 767 int r; 768 769 BUG_ON(td->dm_dev.bdev); 770 771 bdev = blkdev_get_by_dev(dev, td->dm_dev.mode | FMODE_EXCL, _dm_claim_ptr); 772 if (IS_ERR(bdev)) 773 return PTR_ERR(bdev); 774 775 r = bd_link_disk_holder(bdev, dm_disk(md)); 776 if (r) { 777 blkdev_put(bdev, td->dm_dev.mode | FMODE_EXCL); 778 return r; 779 } 780 781 td->dm_dev.bdev = bdev; 782 td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 783 > 784 holders = dax_get_holder(td->dm_dev.dax_dev); 785 if (!holders) { 786 holders = kmalloc(sizeof(*holders), GFP_KERNEL); 787 INIT_LIST_HEAD(holders); > 788 dax_set_holder(td->dm_dev.dax_dev, holders, &dm_dax_holder_ops); 789 } 790 holder = kmalloc(sizeof(*holder), GFP_KERNEL); 791 holder->md = md; 792 list_add_tail(&holder->list, holders); 793 794 return 0; 795 } 796 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ca2aedd8ee7d..606ad74ccf87 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -749,7 +749,11 @@ static void dm_put_live_table_fast(struct mapped_device *md) __releases(RCU) } static char *_dm_claim_ptr = "I belong to device-mapper"; - +static const struct dax_holder_operations dm_dax_holder_ops; +struct dm_holder { + struct list_head list; + struct mapped_device *md; +}; /* * Open a table device so we can use it as a map destination. */ @@ -757,6 +761,8 @@ static int open_table_device(struct table_device *td, dev_t dev, struct mapped_device *md) { struct block_device *bdev; + struct list_head *holders; + struct dm_holder *holder; int r; @@ -774,6 +780,17 @@ static int open_table_device(struct table_device *td, dev_t dev, td->dm_dev.bdev = bdev; td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + + holders = dax_get_holder(td->dm_dev.dax_dev); + if (!holders) { + holders = kmalloc(sizeof(*holders), GFP_KERNEL); + INIT_LIST_HEAD(holders); + dax_set_holder(td->dm_dev.dax_dev, holders, &dm_dax_holder_ops); + } + holder = kmalloc(sizeof(*holder), GFP_KERNEL); + holder->md = md; + list_add_tail(&holder->list, holders); + return 0; } @@ -782,9 +799,24 @@ static int open_table_device(struct table_device *td, dev_t dev, */ static void close_table_device(struct table_device *td, struct mapped_device *md) { + struct list_head *holders; + struct dm_holder *holder, *n; + if (!td->dm_dev.bdev) return; + holders = dax_get_holder(td->dm_dev.dax_dev); + if (holders) { + list_for_each_entry_safe(holder, n, holders, list) { + if (holder->md == md) { + list_del(&holder->list); + kfree(holder); + } + } + if (list_empty(holders)) + kfree(holders); + } + bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); put_dax(td->dm_dev.dax_dev); @@ -1235,6 +1267,87 @@ static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, return ret; } +struct corrupted_hit_info { + struct block_device *bdev; + sector_t offset; +}; + +static int dm_blk_corrupted_hit(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t count, void *data) +{ + struct corrupted_hit_info *bc = data; + + return bc->bdev == (void *)dev->bdev && + (start <= bc->offset && bc->offset < start + count); +} + +struct corrupted_do_info { + size_t length; + void *data; +}; + +static int dm_blk_corrupted_do(struct dm_target *ti, struct block_device *bdev, + sector_t sector, void *data) +{ + struct mapped_device *md = ti->table->md; + struct corrupted_do_info *bc = data; + struct block_device *md_bdev = bdget_disk_sector(md->disk, sector); + + return dax_corrupted_range(md->dax_dev, md_bdev, to_bytes(sector), + bc->length, bc->data); +} + +static int dm_dax_corrputed_range_one(struct mapped_device *md, + struct block_device *bdev, loff_t offset, + size_t length, void *data) +{ + struct dm_table *map; + struct dm_target *ti; + sector_t sect = to_sector(offset); + struct corrupted_hit_info hi = {bdev, sect}; + struct corrupted_do_info di = {length, data}; + int srcu_idx, i, rc = -ENODEV; + + map = dm_get_live_table(md, &srcu_idx); + if (!map) + return rc; + + /* + * find the target device, and then translate the offset of this target + * to the whole mapped device. + */ + for (i = 0; i < dm_table_get_num_targets(map); i++) { + ti = dm_table_get_target(map, i); + if (!(ti->type->iterate_devices && ti->type->rmap)) + continue; + if (!ti->type->iterate_devices(ti, dm_blk_corrupted_hit, &hi)) + continue; + + rc = ti->type->rmap(ti, sect, dm_blk_corrupted_do, &di); + break; + } + + dm_put_live_table(md, srcu_idx); + return rc; +} + +static int dm_dax_corrputed_range(struct dax_device *dax_dev, + struct block_device *bdev, + loff_t offset, size_t length, void *data) +{ + struct dm_holder *holder; + struct list_head *holders = dax_get_holder(dax_dev); + int rc = -ENODEV; + + list_for_each_entry(holder, holders, list) { + rc = dm_dax_corrputed_range_one(holder->md, bdev, offset, + length, data); + if (rc != -ENODEV) + break; + } + return rc; +} + /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_RESET, @@ -3157,6 +3270,10 @@ static const struct dax_operations dm_dax_ops = { .zero_page_range = dm_dax_zero_page_range, }; +static const struct dax_holder_operations dm_dax_holder_ops = { + .corrupted_range = dm_dax_corrputed_range, +}; + /* * module hooks */
This is the case where the holder represents a mapped device, or a list of mapped devices more exactly(because it is possible to create more than one mapped device on one pmem device). Find out which mapped device the offset belongs to, and translate the offset from target device to mapped device. When it is done, call dax_corrupted_range() for the holder of this mapped device. Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> --- drivers/md/dm.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-)