Re: [PATCH next 2/3] debugfs: introduce debugfs_create_single[,_data]
by Dan Carpenter
[ How do I fetch 0day git branchs?
git fetch https://github.com/0day-ci/linux/commits/Kefeng-Wang/debugfs-introduce-de...
doesn't work. - dan ]
Hi Kefeng,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on next-20191128]
[cannot apply to v5.4]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Kefeng-Wang/debugfs-introduce-de...
base: d26b0e226f222c22c3b7e9d16e5b886e7c51057a
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
New smatch warnings:
fs/debugfs/file.c:1193 debugfs_create_single_data() warn: overwrite may leak 'entry'
Old smatch warnings:
include/linux/compiler.h:247 __write_once_size() warn: potential memory corrupting cast 8 vs 4 bytes
# https://github.com/0day-ci/linux/commit/198a4ea9768d6790a169e8b802e702c20...
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 198a4ea9768d6790a169e8b802e702c208aafbd1
vim +/entry +1193 fs/debugfs/file.c
198a4ea9768d67 Kefeng Wang 2019-11-29 1179 struct dentry *debugfs_create_single_data(const char *name, umode_t mode,
198a4ea9768d67 Kefeng Wang 2019-11-29 1180 struct dentry *parent, void *data,
198a4ea9768d67 Kefeng Wang 2019-11-29 1181 int (*read_fn)(struct seq_file *s,
198a4ea9768d67 Kefeng Wang 2019-11-29 1182 void *data))
198a4ea9768d67 Kefeng Wang 2019-11-29 1183 {
198a4ea9768d67 Kefeng Wang 2019-11-29 1184 struct debugfs_entry *entry;
198a4ea9768d67 Kefeng Wang 2019-11-29 1185
198a4ea9768d67 Kefeng Wang 2019-11-29 1186 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
198a4ea9768d67 Kefeng Wang 2019-11-29 1187 if (!entry)
198a4ea9768d67 Kefeng Wang 2019-11-29 1188 return ERR_PTR(-ENOMEM);
198a4ea9768d67 Kefeng Wang 2019-11-29 1189
198a4ea9768d67 Kefeng Wang 2019-11-29 1190 entry->read = read_fn;
198a4ea9768d67 Kefeng Wang 2019-11-29 1191 entry->data = data;
198a4ea9768d67 Kefeng Wang 2019-11-29 1192
198a4ea9768d67 Kefeng Wang 2019-11-29 @1193 entry = debugfs_set_lowest_bit(entry);
^^^^^^^^
I haven't looked at the surrounding code but how would we free "entry"
when we write over it here?
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 4 months
Re: [PATCH 3/4] printk: Drop pr_warning definition
by kbuild test robot
Hi Kefeng,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on wq/for-next]
[cannot apply to pmladek/for-next v5.4 next-20191127]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Kefeng-Wang/part2-kill-pr_warnin...
base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next
config: i386-defconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
drivers/platform/x86/eeepc-laptop.c: In function 'eeepc_rfkill_hotplug':
>> drivers/platform/x86/eeepc-laptop.c:581:3: error: implicit declaration of function 'pr_warning'; did you mean 'acpi_warning'? [-Werror=implicit-function-declaration]
pr_warning("Unable to find port\n");
^~~~~~~~~~
acpi_warning
cc1: some warnings being treated as errors
--
drivers/video/console/vgacon.c: In function 'text_mode':
>> drivers/video/console/vgacon.c:116:2: error: implicit declaration of function 'pr_warning'; did you mean 'pr_warn'? [-Werror=implicit-function-declaration]
pr_warning("You have booted with nomodeset. This means your GPU drivers are DISABLED\n");
^~~~~~~~~~
pr_warn
cc1: some warnings being treated as errors
--
arch/x86//kernel/tsc_sync.c: In function 'check_tsc_sync_source':
>> arch/x86//kernel/tsc_sync.c:367:3: error: implicit declaration of function 'pr_warning'; did you mean 'pr_warn'? [-Werror=implicit-function-declaration]
pr_warning("TSC synchronization [CPU#%d -> CPU#%d]:\n",
^~~~~~~~~~
pr_warn
cc1: some warnings being treated as errors
--
arch/x86//kernel/setup_percpu.c: In function 'setup_per_cpu_areas':
>> arch/x86//kernel/setup_percpu.c:210:4: error: implicit declaration of function 'pr_warning'; did you mean 'pr_warn'? [-Werror=implicit-function-declaration]
pr_warning("%s allocator failed (%d), falling back to page size\n",
^~~~~~~~~~
pr_warn
cc1: some warnings being treated as errors
--
arch/x86//kernel/apic/apic.c: In function 'calibrate_by_pmtimer':
>> arch/x86//kernel/apic/apic.c:783:2: error: implicit declaration of function 'pr_warning'; did you mean 'acpi_warning'? [-Werror=implicit-function-declaration]
pr_warning("APIC calibration not consistent "
^~~~~~~~~~
acpi_warning
cc1: some warnings being treated as errors
--
drivers//acpi/resource.c: In function 'acpi_dev_get_irqresource':
>> drivers//acpi/resource.c:416:4: error: implicit declaration of function 'pr_warning'; did you mean 'acpi_warning'? [-Werror=implicit-function-declaration]
pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi,
^~~~~~~~~~
acpi_warning
cc1: some warnings being treated as errors
vim +581 drivers/platform/x86/eeepc-laptop.c
2b121bc262fa03 Corentin Chary 2009-06-25 560
14fdb152416c0f Matthew Garrett 2011-05-09 561 static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
5740294ca3a9b1 Matthew Garrett 2009-01-20 562 {
14fdb152416c0f Matthew Garrett 2011-05-09 563 struct pci_dev *port;
5740294ca3a9b1 Matthew Garrett 2009-01-20 564 struct pci_dev *dev;
6d41839e762f8b Alan Jenkins 2009-08-28 565 struct pci_bus *bus;
854c78363f37f0 Alan Jenkins 2009-12-03 566 bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
bc9d24a3aeb153 Alan Jenkins 2010-02-22 567 bool absent;
bc9d24a3aeb153 Alan Jenkins 2010-02-22 568 u32 l;
5740294ca3a9b1 Matthew Garrett 2009-01-20 569
a7624b63fdf50d Alan Jenkins 2009-12-03 570 if (eeepc->wlan_rfkill)
a7624b63fdf50d Alan Jenkins 2009-12-03 571 rfkill_set_sw_state(eeepc->wlan_rfkill, blocked);
6d41839e762f8b Alan Jenkins 2009-08-28 572
a7624b63fdf50d Alan Jenkins 2009-12-03 573 mutex_lock(&eeepc->hotplug_lock);
8b9ec1da6a310b Rafael J. Wysocki 2014-01-10 574 pci_lock_rescan_remove();
dcf443b5813074 Alan Jenkins 2009-08-28 575
125450f814418b Lukas Wunner 2018-09-08 576 if (!eeepc->hotplug_slot.ops)
248d4903639068 Frans Klaver 2014-10-22 577 goto out_unlock;
248d4903639068 Frans Klaver 2014-10-22 578
14fdb152416c0f Matthew Garrett 2011-05-09 579 port = acpi_get_pci_dev(handle);
14fdb152416c0f Matthew Garrett 2011-05-09 580 if (!port) {
14fdb152416c0f Matthew Garrett 2011-05-09 @581 pr_warning("Unable to find port\n");
14fdb152416c0f Matthew Garrett 2011-05-09 582 goto out_unlock;
14fdb152416c0f Matthew Garrett 2011-05-09 583 }
14fdb152416c0f Matthew Garrett 2011-05-09 584
14fdb152416c0f Matthew Garrett 2011-05-09 585 bus = port->subordinate;
14fdb152416c0f Matthew Garrett 2011-05-09 586
5740294ca3a9b1 Matthew Garrett 2009-01-20 587 if (!bus) {
22441ffeed17b9 Joe Perches 2011-03-29 588 pr_warn("Unable to find PCI bus 1?\n");
f661848b74b330 Jiang Liu 2012-09-14 589 goto out_put_dev;
5740294ca3a9b1 Matthew Garrett 2009-01-20 590 }
5740294ca3a9b1 Matthew Garrett 2009-01-20 591
bc9d24a3aeb153 Alan Jenkins 2010-02-22 592 if (pci_bus_read_config_dword(bus, 0, PCI_VENDOR_ID, &l)) {
bc9d24a3aeb153 Alan Jenkins 2010-02-22 593 pr_err("Unable to read PCI config space?\n");
f661848b74b330 Jiang Liu 2012-09-14 594 goto out_put_dev;
bc9d24a3aeb153 Alan Jenkins 2010-02-22 595 }
14fdb152416c0f Matthew Garrett 2011-05-09 596
bc9d24a3aeb153 Alan Jenkins 2010-02-22 597 absent = (l == 0xffffffff);
bc9d24a3aeb153 Alan Jenkins 2010-02-22 598
bc9d24a3aeb153 Alan Jenkins 2010-02-22 599 if (blocked != absent) {
9f662b20d6cef8 Frans Klaver 2014-10-22 600 pr_warn("BIOS says wireless lan is %s, but the pci device is %s\n",
bc9d24a3aeb153 Alan Jenkins 2010-02-22 601 blocked ? "blocked" : "unblocked",
bc9d24a3aeb153 Alan Jenkins 2010-02-22 602 absent ? "absent" : "present");
9f662b20d6cef8 Frans Klaver 2014-10-22 603 pr_warn("skipped wireless hotplug as probably inappropriate for this model\n");
f661848b74b330 Jiang Liu 2012-09-14 604 goto out_put_dev;
bc9d24a3aeb153 Alan Jenkins 2010-02-22 605 }
bc9d24a3aeb153 Alan Jenkins 2010-02-22 606
19d337dff95cbf Johannes Berg 2009-06-02 607 if (!blocked) {
5740294ca3a9b1 Matthew Garrett 2009-01-20 608 dev = pci_get_slot(bus, 0);
5740294ca3a9b1 Matthew Garrett 2009-01-20 609 if (dev) {
5740294ca3a9b1 Matthew Garrett 2009-01-20 610 /* Device already present */
5740294ca3a9b1 Matthew Garrett 2009-01-20 611 pci_dev_put(dev);
f661848b74b330 Jiang Liu 2012-09-14 612 goto out_put_dev;
5740294ca3a9b1 Matthew Garrett 2009-01-20 613 }
5740294ca3a9b1 Matthew Garrett 2009-01-20 614 dev = pci_scan_single_device(bus, 0);
5740294ca3a9b1 Matthew Garrett 2009-01-20 615 if (dev) {
5740294ca3a9b1 Matthew Garrett 2009-01-20 616 pci_bus_assign_resources(bus);
c893d133eaccdd Yijing Wang 2014-05-30 617 pci_bus_add_device(dev);
5740294ca3a9b1 Matthew Garrett 2009-01-20 618 }
5740294ca3a9b1 Matthew Garrett 2009-01-20 619 } else {
5740294ca3a9b1 Matthew Garrett 2009-01-20 620 dev = pci_get_slot(bus, 0);
5740294ca3a9b1 Matthew Garrett 2009-01-20 621 if (dev) {
210647af897af8 Yinghai Lu 2012-02-25 622 pci_stop_and_remove_bus_device(dev);
5740294ca3a9b1 Matthew Garrett 2009-01-20 623 pci_dev_put(dev);
5740294ca3a9b1 Matthew Garrett 2009-01-20 624 }
5740294ca3a9b1 Matthew Garrett 2009-01-20 625 }
f661848b74b330 Jiang Liu 2012-09-14 626 out_put_dev:
f661848b74b330 Jiang Liu 2012-09-14 627 pci_dev_put(port);
dcf443b5813074 Alan Jenkins 2009-08-28 628
dcf443b5813074 Alan Jenkins 2009-08-28 629 out_unlock:
8b9ec1da6a310b Rafael J. Wysocki 2014-01-10 630 pci_unlock_rescan_remove();
a7624b63fdf50d Alan Jenkins 2009-12-03 631 mutex_unlock(&eeepc->hotplug_lock);
5740294ca3a9b1 Matthew Garrett 2009-01-20 632 }
5740294ca3a9b1 Matthew Garrett 2009-01-20 633
:::::: The code at line 581 was first introduced by commit
:::::: 14fdb152416c0fab80ecddf492c129d7da1bb8ef eeepc-laptop: Use ACPI handle to identify rfkill port
:::::: TO: Matthew Garrett <mjg(a)redhat.com>
:::::: CC: Matthew Garrett <mjg(a)redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 4 months
[lkp] [+1677 bytes kernel size regression] [i386-tinyconfig] [017e00ec29] perf/x86/intel/lbr: Support Architectural LBRs
by kbuild test robot
FYI, we noticed a +1677 bytes kernel size regression due to commit:
commit: 017e00ec2900c0ce189f5d55681ab0356a3018b4 (perf/x86/intel/lbr: Support Architectural LBRs)
Details as below (size data is obtained by `nm --size-sort vmlinux`):
ad72a568: perf/x86/intel/lbr: Remove valid_lbrs from struct x86_perf_task_context
017e00ec: perf/x86/intel/lbr: Support Architectural LBRs
+---------------------------------+----------+----------+-------+
| symbol | ad72a568 | 017e00ec | delta |
+---------------------------------+----------+----------+-------+
| bzImage | 439936 | 440800 | 864 |
| nm.T.intel_pmu_lbr_read | 851 | 1324 | 473 |
| nm.T.intel_pmu_arch_lbr_init | 0 | 339 | 339 |
| nm.T.intel_pmu_lbr_sched_task | 556 | 841 | 285 |
| nm.T.intel_pmu_init | 4493 | 4620 | 127 |
| nm.T.intel_pmu_setup_lbr_filter | 491 | 615 | 124 |
| nm.T.intel_pmu_lbr_enable_all | 122 | 245 | 123 |
| nm.d.arch_lbr_ctl_map | 0 | 68 | 68 |
| nm.d.arch_lbr_br_type_map | 0 | 64 | 64 |
| nm.T.intel_pmu_lbr_reset | 142 | 169 | 27 |
| nm.t.intel_pmu_lbr_filter | 430 | 448 | 18 |
| nm.D.x86_pmu | 340 | 356 | 16 |
| nm.t.intel_pmu_cpu_starting | 256 | 269 | 13 |
| nm.T.intel_cpuc_prepare | 227 | 236 | 9 |
| nm.t.wrlbr_from | 33 | 30 | -3 |
| nm.T.intel_pmu_lbr_disable_all | 39 | 33 | -6 |
+---------------------------------+----------+----------+-------+
Thanks,
Kbuild test robot
1 year, 4 months
[osandov:btrfs-cleanups 7/9] fs/btrfs/tests/inode-tests.c:266:7: error: too many arguments to function 'btrfs_get_extent'
by kbuild test robot
tree: https://github.com/osandov/linux.git btrfs-cleanups
head: e86fb919694d8c57612c5690be77b27313325232
commit: 3012e96179bf1427eca8e26332c7c4475f31c76b [7/9] btrfs: drop create parameter to btrfs_get_extent()
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 3012e96179bf1427eca8e26332c7c4475f31c76b
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=xtensa
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
fs/btrfs/tests/inode-tests.c: In function 'test_btrfs_get_extent':
>> fs/btrfs/tests/inode-tests.c:266:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, 0, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:286:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, 0, (u64)-1, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:308:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:336:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:359:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:387:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:416:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:438:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:472:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:501:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:531:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:564:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:599:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:633:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
In file included from fs/btrfs/tests/inode-tests.c:8:0:
fs/btrfs/tests/../ctree.h:2876:20: note: declared here
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
^~~~~~~~~~~~~~~~
fs/btrfs/tests/inode-tests.c:668:7: error: too many arguments to function 'btrfs_get_extent'
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
^~~~~~~~~~~~~~~~
vim +/btrfs_get_extent +266 fs/btrfs/tests/inode-tests.c
aaedb55bc08f38 Josef Bacik 2013-10-11 217
b9ef22dedde08a Feifei Xu 2016-06-01 218 static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
aaedb55bc08f38 Josef Bacik 2013-10-11 219 {
7c0260ee098db7 Jeff Mahoney 2016-06-20 220 struct btrfs_fs_info *fs_info = NULL;
aaedb55bc08f38 Josef Bacik 2013-10-11 221 struct inode *inode = NULL;
aaedb55bc08f38 Josef Bacik 2013-10-11 222 struct btrfs_root *root = NULL;
aaedb55bc08f38 Josef Bacik 2013-10-11 223 struct extent_map *em = NULL;
aaedb55bc08f38 Josef Bacik 2013-10-11 224 u64 orig_start;
aaedb55bc08f38 Josef Bacik 2013-10-11 225 u64 disk_bytenr;
aaedb55bc08f38 Josef Bacik 2013-10-11 226 u64 offset;
aaedb55bc08f38 Josef Bacik 2013-10-11 227 int ret = -ENOMEM;
aaedb55bc08f38 Josef Bacik 2013-10-11 228
e4fa7469eb7a93 David Sterba 2019-03-18 229 test_msg("running btrfs_get_extent tests");
e4fa7469eb7a93 David Sterba 2019-03-18 230
aaedb55bc08f38 Josef Bacik 2013-10-11 231 inode = btrfs_new_test_inode();
aaedb55bc08f38 Josef Bacik 2013-10-11 232 if (!inode) {
6a060db85d0a81 David Sterba 2019-03-15 233 test_std_err(TEST_ALLOC_INODE);
aaedb55bc08f38 Josef Bacik 2013-10-11 234 return ret;
aaedb55bc08f38 Josef Bacik 2013-10-11 235 }
aaedb55bc08f38 Josef Bacik 2013-10-11 236
6bf9e4bd6a2778 Qu Wenruo 2019-03-13 237 inode->i_mode = S_IFREG;
aaedb55bc08f38 Josef Bacik 2013-10-11 238 BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
aaedb55bc08f38 Josef Bacik 2013-10-11 239 BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID;
aaedb55bc08f38 Josef Bacik 2013-10-11 240 BTRFS_I(inode)->location.offset = 0;
aaedb55bc08f38 Josef Bacik 2013-10-11 241
da17066c40472c Jeff Mahoney 2016-06-15 242 fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
7c0260ee098db7 Jeff Mahoney 2016-06-20 243 if (!fs_info) {
37b2a7bc1ea919 David Sterba 2019-03-15 244 test_std_err(TEST_ALLOC_FS_INFO);
aaedb55bc08f38 Josef Bacik 2013-10-11 245 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 246 }
aaedb55bc08f38 Josef Bacik 2013-10-11 247
da17066c40472c Jeff Mahoney 2016-06-15 248 root = btrfs_alloc_dummy_root(fs_info);
7c0260ee098db7 Jeff Mahoney 2016-06-20 249 if (IS_ERR(root)) {
52ab7bca3583fa David Sterba 2019-03-15 250 test_std_err(TEST_ALLOC_ROOT);
aaedb55bc08f38 Josef Bacik 2013-10-11 251 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 252 }
aaedb55bc08f38 Josef Bacik 2013-10-11 253
da17066c40472c Jeff Mahoney 2016-06-15 254 root->node = alloc_dummy_extent_buffer(fs_info, nodesize);
aaedb55bc08f38 Josef Bacik 2013-10-11 255 if (!root->node) {
9e3d9f8462ef02 David Sterba 2019-03-15 256 test_std_err(TEST_ALLOC_ROOT);
aaedb55bc08f38 Josef Bacik 2013-10-11 257 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 258 }
aaedb55bc08f38 Josef Bacik 2013-10-11 259
aaedb55bc08f38 Josef Bacik 2013-10-11 260 btrfs_set_header_nritems(root->node, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 261 btrfs_set_header_level(root->node, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 262 ret = -EINVAL;
aaedb55bc08f38 Josef Bacik 2013-10-11 263
aaedb55bc08f38 Josef Bacik 2013-10-11 264 /* First with no extents */
aaedb55bc08f38 Josef Bacik 2013-10-11 265 BTRFS_I(inode)->root = root;
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 @266 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, 0, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 267 if (IS_ERR(em)) {
aaedb55bc08f38 Josef Bacik 2013-10-11 268 em = NULL;
3c7251f2f88880 David Sterba 2018-05-17 269 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 270 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 271 }
aaedb55bc08f38 Josef Bacik 2013-10-11 272 if (em->block_start != EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 273 test_err("expected a hole, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 274 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 275 }
aaedb55bc08f38 Josef Bacik 2013-10-11 276 free_extent_map(em);
dcdbc059f01e24 Nikolay Borisov 2017-02-20 277 btrfs_drop_extent_cache(BTRFS_I(inode), 0, (u64)-1, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 278
aaedb55bc08f38 Josef Bacik 2013-10-11 279 /*
aaedb55bc08f38 Josef Bacik 2013-10-11 280 * All of the magic numbers are based on the mapping setup in
aaedb55bc08f38 Josef Bacik 2013-10-11 281 * setup_file_extents, so if you change anything there you need to
aaedb55bc08f38 Josef Bacik 2013-10-11 282 * update the comment and update the expected values below.
aaedb55bc08f38 Josef Bacik 2013-10-11 283 */
b9ef22dedde08a Feifei Xu 2016-06-01 284 setup_file_extents(root, sectorsize);
aaedb55bc08f38 Josef Bacik 2013-10-11 285
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 286 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, 0, (u64)-1, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 287 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 288 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 289 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 290 }
aaedb55bc08f38 Josef Bacik 2013-10-11 291 if (em->block_start != EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 292 test_err("expected a hole, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 293 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 294 }
aaedb55bc08f38 Josef Bacik 2013-10-11 295 if (em->start != 0 || em->len != 5) {
3c7251f2f88880 David Sterba 2018-05-17 296 test_err(
3c7251f2f88880 David Sterba 2018-05-17 297 "unexpected extent wanted start 0 len 5, got start %llu len %llu",
3c7251f2f88880 David Sterba 2018-05-17 298 em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 299 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 300 }
aaedb55bc08f38 Josef Bacik 2013-10-11 301 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 302 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 303 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 304 }
aaedb55bc08f38 Josef Bacik 2013-10-11 305 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 306 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 307
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 308 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 309 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 310 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 311 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 312 }
aaedb55bc08f38 Josef Bacik 2013-10-11 313 if (em->block_start != EXTENT_MAP_INLINE) {
3c7251f2f88880 David Sterba 2018-05-17 314 test_err("expected an inline, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 315 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 316 }
b9ef22dedde08a Feifei Xu 2016-06-01 317
b9ef22dedde08a Feifei Xu 2016-06-01 318 if (em->start != offset || em->len != (sectorsize - 5)) {
3c7251f2f88880 David Sterba 2018-05-17 319 test_err(
3c7251f2f88880 David Sterba 2018-05-17 320 "unexpected extent wanted start %llu len 1, got start %llu len %llu",
3c7251f2f88880 David Sterba 2018-05-17 321 offset, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 322 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 323 }
aaedb55bc08f38 Josef Bacik 2013-10-11 324 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 325 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 326 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 327 }
aaedb55bc08f38 Josef Bacik 2013-10-11 328 /*
aaedb55bc08f38 Josef Bacik 2013-10-11 329 * We don't test anything else for inline since it doesn't get set
aaedb55bc08f38 Josef Bacik 2013-10-11 330 * unless we have a page for it to write into. Maybe we should change
aaedb55bc08f38 Josef Bacik 2013-10-11 331 * this?
aaedb55bc08f38 Josef Bacik 2013-10-11 332 */
aaedb55bc08f38 Josef Bacik 2013-10-11 333 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 334 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 335
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 336 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 337 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 338 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 339 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 340 }
aaedb55bc08f38 Josef Bacik 2013-10-11 341 if (em->block_start != EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 342 test_err("expected a hole, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 343 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 344 }
aaedb55bc08f38 Josef Bacik 2013-10-11 345 if (em->start != offset || em->len != 4) {
3c7251f2f88880 David Sterba 2018-05-17 346 test_err(
3c7251f2f88880 David Sterba 2018-05-17 347 "unexpected extent wanted start %llu len 4, got start %llu len %llu",
3c7251f2f88880 David Sterba 2018-05-17 348 offset, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 349 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 350 }
aaedb55bc08f38 Josef Bacik 2013-10-11 351 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 352 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 353 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 354 }
aaedb55bc08f38 Josef Bacik 2013-10-11 355 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 356 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 357
aaedb55bc08f38 Josef Bacik 2013-10-11 358 /* Regular extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 359 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 360 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 361 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 362 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 363 }
aaedb55bc08f38 Josef Bacik 2013-10-11 364 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 365 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 366 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 367 }
b9ef22dedde08a Feifei Xu 2016-06-01 368 if (em->start != offset || em->len != sectorsize - 1) {
3c7251f2f88880 David Sterba 2018-05-17 369 test_err(
3c7251f2f88880 David Sterba 2018-05-17 370 "unexpected extent wanted start %llu len 4095, got start %llu len %llu",
3c7251f2f88880 David Sterba 2018-05-17 371 offset, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 372 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 373 }
aaedb55bc08f38 Josef Bacik 2013-10-11 374 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 375 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 376 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 377 }
aaedb55bc08f38 Josef Bacik 2013-10-11 378 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 379 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 380 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 381 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 382 }
aaedb55bc08f38 Josef Bacik 2013-10-11 383 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 384 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 385
aaedb55bc08f38 Josef Bacik 2013-10-11 386 /* The next 3 are split extents */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 387 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 388 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 389 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 390 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 391 }
aaedb55bc08f38 Josef Bacik 2013-10-11 392 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 393 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 394 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 395 }
b9ef22dedde08a Feifei Xu 2016-06-01 396 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 397 test_err(
3c7251f2f88880 David Sterba 2018-05-17 398 "unexpected extent start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 399 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 400 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 401 }
aaedb55bc08f38 Josef Bacik 2013-10-11 402 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 403 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 404 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 405 }
aaedb55bc08f38 Josef Bacik 2013-10-11 406 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 407 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 408 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 409 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 410 }
aaedb55bc08f38 Josef Bacik 2013-10-11 411 disk_bytenr = em->block_start;
aaedb55bc08f38 Josef Bacik 2013-10-11 412 orig_start = em->start;
aaedb55bc08f38 Josef Bacik 2013-10-11 413 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 414 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 415
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 416 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 417 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 418 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 419 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 420 }
aaedb55bc08f38 Josef Bacik 2013-10-11 421 if (em->block_start != EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 422 test_err("expected a hole, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 423 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 424 }
b9ef22dedde08a Feifei Xu 2016-06-01 425 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 426 test_err(
3c7251f2f88880 David Sterba 2018-05-17 427 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 428 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 429 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 430 }
aaedb55bc08f38 Josef Bacik 2013-10-11 431 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 432 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 433 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 434 }
aaedb55bc08f38 Josef Bacik 2013-10-11 435 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 436 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 437
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 438 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 439 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 440 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 441 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 442 }
aaedb55bc08f38 Josef Bacik 2013-10-11 443 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 444 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 445 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 446 }
b9ef22dedde08a Feifei Xu 2016-06-01 447 if (em->start != offset || em->len != 2 * sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 448 test_err(
3c7251f2f88880 David Sterba 2018-05-17 449 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 450 offset, 2 * sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 451 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 452 }
aaedb55bc08f38 Josef Bacik 2013-10-11 453 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 454 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 455 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 456 }
aaedb55bc08f38 Josef Bacik 2013-10-11 457 if (em->orig_start != orig_start) {
3c7251f2f88880 David Sterba 2018-05-17 458 test_err("wrong orig offset, want %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 459 orig_start, em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 460 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 461 }
aaedb55bc08f38 Josef Bacik 2013-10-11 462 disk_bytenr += (em->start - orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 463 if (em->block_start != disk_bytenr) {
3c7251f2f88880 David Sterba 2018-05-17 464 test_err("wrong block start, want %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 465 disk_bytenr, em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 466 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 467 }
aaedb55bc08f38 Josef Bacik 2013-10-11 468 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 469 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 470
aaedb55bc08f38 Josef Bacik 2013-10-11 471 /* Prealloc extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 472 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 473 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 474 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 475 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 476 }
aaedb55bc08f38 Josef Bacik 2013-10-11 477 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 478 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 479 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 480 }
b9ef22dedde08a Feifei Xu 2016-06-01 481 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 482 test_err(
3c7251f2f88880 David Sterba 2018-05-17 483 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 484 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 485 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 486 }
aaedb55bc08f38 Josef Bacik 2013-10-11 487 if (em->flags != prealloc_only) {
3c7251f2f88880 David Sterba 2018-05-17 488 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 489 prealloc_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 490 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 491 }
aaedb55bc08f38 Josef Bacik 2013-10-11 492 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 493 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 494 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 495 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 496 }
aaedb55bc08f38 Josef Bacik 2013-10-11 497 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 498 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 499
aaedb55bc08f38 Josef Bacik 2013-10-11 500 /* The next 3 are a half written prealloc extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 501 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 502 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 503 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 504 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 505 }
aaedb55bc08f38 Josef Bacik 2013-10-11 506 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 507 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 508 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 509 }
b9ef22dedde08a Feifei Xu 2016-06-01 510 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 511 test_err(
3c7251f2f88880 David Sterba 2018-05-17 512 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 513 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 514 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 515 }
aaedb55bc08f38 Josef Bacik 2013-10-11 516 if (em->flags != prealloc_only) {
3c7251f2f88880 David Sterba 2018-05-17 517 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 518 prealloc_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 519 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 520 }
aaedb55bc08f38 Josef Bacik 2013-10-11 521 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 522 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 523 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 524 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 525 }
aaedb55bc08f38 Josef Bacik 2013-10-11 526 disk_bytenr = em->block_start;
aaedb55bc08f38 Josef Bacik 2013-10-11 527 orig_start = em->start;
aaedb55bc08f38 Josef Bacik 2013-10-11 528 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 529 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 530
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 531 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 532 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 533 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 534 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 535 }
aaedb55bc08f38 Josef Bacik 2013-10-11 536 if (em->block_start >= EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 537 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 538 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 539 }
b9ef22dedde08a Feifei Xu 2016-06-01 540 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 541 test_err(
3c7251f2f88880 David Sterba 2018-05-17 542 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 543 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 544 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 545 }
aaedb55bc08f38 Josef Bacik 2013-10-11 546 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 547 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 548 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 549 }
aaedb55bc08f38 Josef Bacik 2013-10-11 550 if (em->orig_start != orig_start) {
3c7251f2f88880 David Sterba 2018-05-17 551 test_err("unexpected orig offset, wanted %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 552 orig_start, em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 553 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 554 }
aaedb55bc08f38 Josef Bacik 2013-10-11 555 if (em->block_start != (disk_bytenr + (em->start - em->orig_start))) {
3c7251f2f88880 David Sterba 2018-05-17 556 test_err("unexpected block start, wanted %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 557 disk_bytenr + (em->start - em->orig_start),
aaedb55bc08f38 Josef Bacik 2013-10-11 558 em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 559 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 560 }
aaedb55bc08f38 Josef Bacik 2013-10-11 561 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 562 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 563
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 564 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 565 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 566 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 567 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 568 }
aaedb55bc08f38 Josef Bacik 2013-10-11 569 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 570 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 571 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 572 }
b9ef22dedde08a Feifei Xu 2016-06-01 573 if (em->start != offset || em->len != 2 * sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 574 test_err(
3c7251f2f88880 David Sterba 2018-05-17 575 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 576 offset, 2 * sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 577 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 578 }
aaedb55bc08f38 Josef Bacik 2013-10-11 579 if (em->flags != prealloc_only) {
3c7251f2f88880 David Sterba 2018-05-17 580 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 581 prealloc_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 582 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 583 }
aaedb55bc08f38 Josef Bacik 2013-10-11 584 if (em->orig_start != orig_start) {
3c7251f2f88880 David Sterba 2018-05-17 585 test_err("wrong orig offset, want %llu, have %llu", orig_start,
aaedb55bc08f38 Josef Bacik 2013-10-11 586 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 587 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 588 }
aaedb55bc08f38 Josef Bacik 2013-10-11 589 if (em->block_start != (disk_bytenr + (em->start - em->orig_start))) {
3c7251f2f88880 David Sterba 2018-05-17 590 test_err("unexpected block start, wanted %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 591 disk_bytenr + (em->start - em->orig_start),
aaedb55bc08f38 Josef Bacik 2013-10-11 592 em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 593 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 594 }
aaedb55bc08f38 Josef Bacik 2013-10-11 595 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 596 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 597
aaedb55bc08f38 Josef Bacik 2013-10-11 598 /* Now for the compressed extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 599 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 600 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 601 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 602 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 603 }
aaedb55bc08f38 Josef Bacik 2013-10-11 604 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 605 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 606 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 607 }
b9ef22dedde08a Feifei Xu 2016-06-01 608 if (em->start != offset || em->len != 2 * sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 609 test_err(
3c7251f2f88880 David Sterba 2018-05-17 610 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 611 offset, 2 * sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 612 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 613 }
aaedb55bc08f38 Josef Bacik 2013-10-11 614 if (em->flags != compressed_only) {
3c7251f2f88880 David Sterba 2018-05-17 615 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 616 compressed_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 617 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 618 }
aaedb55bc08f38 Josef Bacik 2013-10-11 619 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 620 test_err("wrong orig offset, want %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 621 em->start, em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 622 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 623 }
aaedb55bc08f38 Josef Bacik 2013-10-11 624 if (em->compress_type != BTRFS_COMPRESS_ZLIB) {
3c7251f2f88880 David Sterba 2018-05-17 625 test_err("unexpected compress type, wanted %d, got %d",
aaedb55bc08f38 Josef Bacik 2013-10-11 626 BTRFS_COMPRESS_ZLIB, em->compress_type);
aaedb55bc08f38 Josef Bacik 2013-10-11 627 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 628 }
aaedb55bc08f38 Josef Bacik 2013-10-11 629 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 630 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 631
aaedb55bc08f38 Josef Bacik 2013-10-11 632 /* Split compressed extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 633 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 634 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 635 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 636 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 637 }
aaedb55bc08f38 Josef Bacik 2013-10-11 638 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 639 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 640 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 641 }
b9ef22dedde08a Feifei Xu 2016-06-01 642 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 643 test_err(
3c7251f2f88880 David Sterba 2018-05-17 644 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 645 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 646 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 647 }
aaedb55bc08f38 Josef Bacik 2013-10-11 648 if (em->flags != compressed_only) {
3c7251f2f88880 David Sterba 2018-05-17 649 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 650 compressed_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 651 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 652 }
aaedb55bc08f38 Josef Bacik 2013-10-11 653 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 654 test_err("wrong orig offset, want %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 655 em->start, em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 656 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 657 }
aaedb55bc08f38 Josef Bacik 2013-10-11 658 if (em->compress_type != BTRFS_COMPRESS_ZLIB) {
3c7251f2f88880 David Sterba 2018-05-17 659 test_err("unexpected compress type, wanted %d, got %d",
aaedb55bc08f38 Josef Bacik 2013-10-11 660 BTRFS_COMPRESS_ZLIB, em->compress_type);
aaedb55bc08f38 Josef Bacik 2013-10-11 661 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 662 }
aaedb55bc08f38 Josef Bacik 2013-10-11 663 disk_bytenr = em->block_start;
aaedb55bc08f38 Josef Bacik 2013-10-11 664 orig_start = em->start;
aaedb55bc08f38 Josef Bacik 2013-10-11 665 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 666 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 667
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 668 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 669 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 670 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 671 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 672 }
aaedb55bc08f38 Josef Bacik 2013-10-11 673 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 674 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 675 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 676 }
b9ef22dedde08a Feifei Xu 2016-06-01 677 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 678 test_err(
3c7251f2f88880 David Sterba 2018-05-17 679 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 680 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 681 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 682 }
aaedb55bc08f38 Josef Bacik 2013-10-11 683 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 684 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 685 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 686 }
aaedb55bc08f38 Josef Bacik 2013-10-11 687 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 688 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 689 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 690 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 691 }
aaedb55bc08f38 Josef Bacik 2013-10-11 692 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 693 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 694
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 695 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 696 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 697 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 698 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 699 }
aaedb55bc08f38 Josef Bacik 2013-10-11 700 if (em->block_start != disk_bytenr) {
3c7251f2f88880 David Sterba 2018-05-17 701 test_err("block start does not match, want %llu got %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 702 disk_bytenr, em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 703 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 704 }
b9ef22dedde08a Feifei Xu 2016-06-01 705 if (em->start != offset || em->len != 2 * sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 706 test_err(
3c7251f2f88880 David Sterba 2018-05-17 707 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 708 offset, 2 * sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 709 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 710 }
aaedb55bc08f38 Josef Bacik 2013-10-11 711 if (em->flags != compressed_only) {
3c7251f2f88880 David Sterba 2018-05-17 712 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 713 compressed_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 714 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 715 }
aaedb55bc08f38 Josef Bacik 2013-10-11 716 if (em->orig_start != orig_start) {
3c7251f2f88880 David Sterba 2018-05-17 717 test_err("wrong orig offset, want %llu, have %llu",
aaedb55bc08f38 Josef Bacik 2013-10-11 718 em->start, orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 719 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 720 }
aaedb55bc08f38 Josef Bacik 2013-10-11 721 if (em->compress_type != BTRFS_COMPRESS_ZLIB) {
3c7251f2f88880 David Sterba 2018-05-17 722 test_err("unexpected compress type, wanted %d, got %d",
aaedb55bc08f38 Josef Bacik 2013-10-11 723 BTRFS_COMPRESS_ZLIB, em->compress_type);
aaedb55bc08f38 Josef Bacik 2013-10-11 724 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 725 }
aaedb55bc08f38 Josef Bacik 2013-10-11 726 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 727 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 728
aaedb55bc08f38 Josef Bacik 2013-10-11 729 /* A hole between regular extents but no hole extent */
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 730 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset + 6,
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 731 sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 732 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 733 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 734 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 735 }
aaedb55bc08f38 Josef Bacik 2013-10-11 736 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 737 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 738 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 739 }
b9ef22dedde08a Feifei Xu 2016-06-01 740 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 741 test_err(
3c7251f2f88880 David Sterba 2018-05-17 742 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 743 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 744 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 745 }
aaedb55bc08f38 Josef Bacik 2013-10-11 746 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 747 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 748 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 749 }
aaedb55bc08f38 Josef Bacik 2013-10-11 750 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 751 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 752 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 753 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 754 }
aaedb55bc08f38 Josef Bacik 2013-10-11 755 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 756 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 757
d4417e22551377 Nikolay Borisov 2017-10-16 758 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, SZ_4M, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 759 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 760 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 761 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 762 }
aaedb55bc08f38 Josef Bacik 2013-10-11 763 if (em->block_start != EXTENT_MAP_HOLE) {
3c7251f2f88880 David Sterba 2018-05-17 764 test_err("expected a hole extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 765 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 766 }
aaedb55bc08f38 Josef Bacik 2013-10-11 767 /*
aaedb55bc08f38 Josef Bacik 2013-10-11 768 * Currently we just return a length that we requested rather than the
aaedb55bc08f38 Josef Bacik 2013-10-11 769 * length of the actual hole, if this changes we'll have to change this
aaedb55bc08f38 Josef Bacik 2013-10-11 770 * test.
aaedb55bc08f38 Josef Bacik 2013-10-11 771 */
b9ef22dedde08a Feifei Xu 2016-06-01 772 if (em->start != offset || em->len != 3 * sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 773 test_err(
3c7251f2f88880 David Sterba 2018-05-17 774 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 775 offset, 3 * sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 776 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 777 }
aaedb55bc08f38 Josef Bacik 2013-10-11 778 if (em->flags != vacancy_only) {
3c7251f2f88880 David Sterba 2018-05-17 779 test_err("unexpected flags set, want %lu have %lu",
aaedb55bc08f38 Josef Bacik 2013-10-11 780 vacancy_only, em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 781 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 782 }
aaedb55bc08f38 Josef Bacik 2013-10-11 783 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 784 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 785 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 786 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 787 }
aaedb55bc08f38 Josef Bacik 2013-10-11 788 offset = em->start + em->len;
aaedb55bc08f38 Josef Bacik 2013-10-11 789 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 790
fc4f21b1d8d023 Nikolay Borisov 2017-02-20 791 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, sectorsize, 0);
aaedb55bc08f38 Josef Bacik 2013-10-11 792 if (IS_ERR(em)) {
3c7251f2f88880 David Sterba 2018-05-17 793 test_err("got an error when we shouldn't have");
aaedb55bc08f38 Josef Bacik 2013-10-11 794 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 795 }
aaedb55bc08f38 Josef Bacik 2013-10-11 796 if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
3c7251f2f88880 David Sterba 2018-05-17 797 test_err("expected a real extent, got %llu", em->block_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 798 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 799 }
b9ef22dedde08a Feifei Xu 2016-06-01 800 if (em->start != offset || em->len != sectorsize) {
3c7251f2f88880 David Sterba 2018-05-17 801 test_err(
3c7251f2f88880 David Sterba 2018-05-17 802 "unexpected extent wanted start %llu len %u, got start %llu len %llu",
b9ef22dedde08a Feifei Xu 2016-06-01 803 offset, sectorsize, em->start, em->len);
aaedb55bc08f38 Josef Bacik 2013-10-11 804 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 805 }
aaedb55bc08f38 Josef Bacik 2013-10-11 806 if (em->flags != 0) {
3c7251f2f88880 David Sterba 2018-05-17 807 test_err("unexpected flags set, want 0 have %lu", em->flags);
aaedb55bc08f38 Josef Bacik 2013-10-11 808 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 809 }
aaedb55bc08f38 Josef Bacik 2013-10-11 810 if (em->orig_start != em->start) {
3c7251f2f88880 David Sterba 2018-05-17 811 test_err("wrong orig offset, want %llu, have %llu", em->start,
aaedb55bc08f38 Josef Bacik 2013-10-11 812 em->orig_start);
aaedb55bc08f38 Josef Bacik 2013-10-11 813 goto out;
aaedb55bc08f38 Josef Bacik 2013-10-11 814 }
aaedb55bc08f38 Josef Bacik 2013-10-11 815 ret = 0;
aaedb55bc08f38 Josef Bacik 2013-10-11 816 out:
aaedb55bc08f38 Josef Bacik 2013-10-11 817 if (!IS_ERR(em))
aaedb55bc08f38 Josef Bacik 2013-10-11 818 free_extent_map(em);
aaedb55bc08f38 Josef Bacik 2013-10-11 819 iput(inode);
faa2dbf004e89e Josef Bacik 2014-05-07 820 btrfs_free_dummy_root(root);
7c0260ee098db7 Jeff Mahoney 2016-06-20 821 btrfs_free_dummy_fs_info(fs_info);
aaedb55bc08f38 Josef Bacik 2013-10-11 822 return ret;
aaedb55bc08f38 Josef Bacik 2013-10-11 823 }
aaedb55bc08f38 Josef Bacik 2013-10-11 824
:::::: The code at line 266 was first introduced by commit
:::::: fc4f21b1d8d023cf0a2b1b050ae18e15dbe7068e btrfs: Make get_extent_t take btrfs_inode
:::::: TO: Nikolay Borisov <nborisov(a)suse.com>
:::::: CC: David Sterba <dsterba(a)suse.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 4 months