Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-08-03 Thread Mike Christie
On 08/03/2016 11:25 AM, Ross Zwisler wrote:
>  run fstests generic/008 at 2016-08-03 09:54:56
> page:ea0017af04c0 count:3 mapcount:0 mapping:8805eb059200 index:0x0
> flags: 0x3fff802828(uptodate|lru|private|writeback)
> page dumped because: VM_BUG_ON_PAGE(!PageLocked(page))
> page->mem_cgroup:8806098e0800
> [ cut here ]
> kernel BUG at mm/filemap.c:833!
> invalid opcode:  [#1] SMP
> Modules linked in: brd dax_pmem nd_pmem dax nd_btt nd_e820 libnvdimm
> CPU: 0 PID: 2522 Comm: xfs_io Not tainted 4.7.0-rc2-00042-g4e1b2d52 #18
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> rel-1.9.1-0-gb3ef39f-prebuilt.qemu-project.org 04/01/2014
> task: 8805ebae4ec0 ti: 8805eba3c000 task.ti: 8805eba3c000
> RIP: 0010:[] [] unlock_page+0xa5/0xb0
> RSP: 0018:8805eba3fa60 EFLAGS: 00010282
> RAX: 0021 RBX:  RCX: 0006
> RDX:  RSI: 0001 RDI: 8806109ce200
> RBP: 8805eba3fa60 R08: 0001 R09: 0001
> R10: 8805ebae4ec0 R11: 0001 R12: ea0017af04c0
> R13: 00028000 R14: a00202c0 R15: 88060eff1200
> FS: 7f87a31cf700() GS:88061080() knlGS:
> CS: 0010 DS:  ES:  CR0: 80050033
> CR2: 7f87a31e6000 CR3: 00060da31000 CR4: 001406f0
> Stack:
> 8805eba3fa98 812bd782 8805eba3fdb0 1000
> ea0017af04c0  0088 8805eba3fbe0
> 812c3ff1 8805eba3fd00 00028000 000c
> Call Trace:
> [] bdev_write_page+0xb2/0xe0 fs/block_dev.c:462
> [] __mpage_writepage+0x5c1/0x750 fs/mpage.c:604
> [] write_cache_pages+0x20d/0x5f0 mm/page-writeback.c:2261
> [] mpage_writepages+0x75/0xe0 fs/mpage.c:703
> [] ext2_writepages+0x3b/0x40 fs/ext2/inode.c:887
> [] do_writepages+0x21/0x30 mm/page-writeback.c:2361
> [] __filemap_fdatawrite_range+0xc6/0x100 mm/filemap.c:300
> [] filemap_write_and_wait_range+0x44/0x90 mm/filemap.c:490
> [] __generic_file_fsync+0x27/0x90 fs/libfs.c:937
> [] generic_file_fsync+0x19/0x40 fs/libfs.c:974
> [] ext2_fsync+0x2e/0x70 fs/ext2/file.c:149
> [] vfs_fsync_range+0x4b/0xb0 fs/sync.c:195
> [< inline >] vfs_fsync fs/sync.c:209
> [] do_fsync+0x3d/0x70 fs/sync.c:219
> [< inline >] SYSC_fsync fs/sync.c:227
> [] SyS_fsync+0x10/0x20 fs/sync.c:225
> [] entry_SYSCALL_64_fastpath+0x1f/0xbd
> arch/x86/entry/entry_64.S:207
> Code: 00 00 48 d3 ea 89 d2 48 8d 0c 92 48 8d 14 4a 48 8d 3c d0 31 d2
> e8 bc fc f1 ff 5d c3 48 c7 c6 20 1d ec 81 4c 89 c7 e8 bb 8d 03 00 <0f>
> 0b 66 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 b9 08 00 00
> RIP [] unlock_page+0xa5/0xb0 mm/filemap.c:833
> RSP 
> ---[ end trace d419bf59bba263fb ]---


Thanks for testing and the detailed bug report. Looks like I missed the
rw_page callback. Testing a patch right now. Should be done in a couple
of hours.




Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-08-03 Thread Ross Zwisler
On Sun, Jun 5, 2016 at 1:32 PM,   wrote:
> From: Mike Christie 
>
> This patch drops the compat definition of req_op where it matches
> the rq_flag_bits definitions, and drops the related old and compat
> code that allowed users to set either the op or flags for the operation.
>
> We also then store the operation in the bi_rw/cmd_flags field similar
> to how we used to store the bio ioprio where it sat in the upper bits
> of the field.
>
> Signed-off-by: Mike Christie 

I was doing some xfstests testing yesterday using linux/master, and
hit a kernel BUG that bisected to this change.  The failing test is
generic/008 + ext2, without DAX.  This BUG reproduces with this test
100% as of this change, and 0% with the previous commit.

Here's the kernel commit that I bisected to:

commit 4e1b2d52a80d79296a5d899d73249748dea71a53
Author: Mike Christie 
Date:   Sun Jun 5 14:32:22 2016 -0500

block, fs, drivers: remove REQ_OP compat defs and related code

Here are the steps to reproduce the BUG using a pair of 1 GiB BRD ramdisks:

SCRATCH_DEV=/dev/ram0
TEST_DEV=/dev/ram1
mkfs.ext2 -F $SCRATCH_DEV
mkfs.ext2 -F $TEST_DEV
cd ~/xfstests
./check generic/008

Here is the BUG output for that commit, passed through
kasan_symbolize.py.  The line numbers are for the commit listed above,
not for linux/master:

 run fstests generic/008 at 2016-08-03 09:54:56
page:ea0017af04c0 count:3 mapcount:0 mapping:8805eb059200 index:0x0
flags: 0x3fff802828(uptodate|lru|private|writeback)
page dumped because: VM_BUG_ON_PAGE(!PageLocked(page))
page->mem_cgroup:8806098e0800
[ cut here ]
kernel BUG at mm/filemap.c:833!
invalid opcode:  [#1] SMP
Modules linked in: brd dax_pmem nd_pmem dax nd_btt nd_e820 libnvdimm
CPU: 0 PID: 2522 Comm: xfs_io Not tainted 4.7.0-rc2-00042-g4e1b2d52 #18
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.9.1-0-gb3ef39f-prebuilt.qemu-project.org 04/01/2014
task: 8805ebae4ec0 ti: 8805eba3c000 task.ti: 8805eba3c000
RIP: 0010:[] [] unlock_page+0xa5/0xb0
RSP: 0018:8805eba3fa60 EFLAGS: 00010282
RAX: 0021 RBX:  RCX: 0006
RDX:  RSI: 0001 RDI: 8806109ce200
RBP: 8805eba3fa60 R08: 0001 R09: 0001
R10: 8805ebae4ec0 R11: 0001 R12: ea0017af04c0
R13: 00028000 R14: a00202c0 R15: 88060eff1200
FS: 7f87a31cf700() GS:88061080() knlGS:
CS: 0010 DS:  ES:  CR0: 80050033
CR2: 7f87a31e6000 CR3: 00060da31000 CR4: 001406f0
Stack:
8805eba3fa98 812bd782 8805eba3fdb0 1000
ea0017af04c0  0088 8805eba3fbe0
812c3ff1 8805eba3fd00 00028000 000c
Call Trace:
[] bdev_write_page+0xb2/0xe0 fs/block_dev.c:462
[] __mpage_writepage+0x5c1/0x750 fs/mpage.c:604
[] write_cache_pages+0x20d/0x5f0 mm/page-writeback.c:2261
[] mpage_writepages+0x75/0xe0 fs/mpage.c:703
[] ext2_writepages+0x3b/0x40 fs/ext2/inode.c:887
[] do_writepages+0x21/0x30 mm/page-writeback.c:2361
[] __filemap_fdatawrite_range+0xc6/0x100 mm/filemap.c:300
[] filemap_write_and_wait_range+0x44/0x90 mm/filemap.c:490
[] __generic_file_fsync+0x27/0x90 fs/libfs.c:937
[] generic_file_fsync+0x19/0x40 fs/libfs.c:974
[] ext2_fsync+0x2e/0x70 fs/ext2/file.c:149
[] vfs_fsync_range+0x4b/0xb0 fs/sync.c:195
[< inline >] vfs_fsync fs/sync.c:209
[] do_fsync+0x3d/0x70 fs/sync.c:219
[< inline >] SYSC_fsync fs/sync.c:227
[] SyS_fsync+0x10/0x20 fs/sync.c:225
[] entry_SYSCALL_64_fastpath+0x1f/0xbd
arch/x86/entry/entry_64.S:207
Code: 00 00 48 d3 ea 89 d2 48 8d 0c 92 48 8d 14 4a 48 8d 3c d0 31 d2
e8 bc fc f1 ff 5d c3 48 c7 c6 20 1d ec 81 4c 89 c7 e8 bb 8d 03 00 <0f>
0b 66 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 b9 08 00 00
RIP [] unlock_page+0xa5/0xb0 mm/filemap.c:833
RSP 
---[ end trace d419bf59bba263fb ]---

I'm happy to provide any additional info you need, or to test fixes.

Thanks,
- Ross


Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-06-05 Thread Hannes Reinecke
On 06/05/2016 09:32 PM, mchri...@redhat.com wrote:
> From: Mike Christie 
> 
> This patch drops the compat definition of req_op where it matches
> the rq_flag_bits definitions, and drops the related old and compat
> code that allowed users to set either the op or flags for the operation.
> 
> We also then store the operation in the bi_rw/cmd_flags field similar
> to how we used to store the bio ioprio where it sat in the upper bits
> of the field.
> 
> Signed-off-by: Mike Christie 
> ---
>  drivers/scsi/sd.c   |  2 +-
>  include/linux/bio.h |  3 ---
>  include/linux/blk_types.h   | 52 
> +
>  include/linux/blkdev.h  | 14 
>  include/linux/fs.h  | 37 +---
>  include/trace/events/f2fs.h |  1 -
>  6 files changed, 46 insertions(+), 63 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-06-05 Thread kbuild test robot
Hi,

[auto build test ERROR on v4.7-rc1]
[cannot apply to dm/for-next md/for-next next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/mchristi-redhat-com/v8-separate-operations-from-flags-in-the-bio-request-structs/20160606-040240
config: blackfin-BF526-EZBRD_defconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 4.6.3
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `sd_init_command':
>> drivers/scsi/sd.c:1141: undefined reference to `__ucmpdi2'

vim +1141 drivers/scsi/sd.c

^1da177e Linus Torvalds2005-04-16  1135  }
^1da177e Linus Torvalds2005-04-16  1136  
87949eee Christoph Hellwig 2014-06-28  1137  static int sd_init_command(struct 
scsi_cmnd *cmd)
87949eee Christoph Hellwig 2014-06-28  1138  {
87949eee Christoph Hellwig 2014-06-28  1139 struct request *rq = 
cmd->request;
87949eee Christoph Hellwig 2014-06-28  1140  
b826ba83 Mike Christie 2016-06-05 @1141 switch (req_op(rq)) {
b826ba83 Mike Christie 2016-06-05  1142 case REQ_OP_DISCARD:
87949eee Christoph Hellwig 2014-06-28  1143 return 
sd_setup_discard_cmnd(cmd);
b826ba83 Mike Christie 2016-06-05  1144 case REQ_OP_WRITE_SAME:

:: The code at line 1141 was first introduced by commit
:: b826ba83985b86029288d8cc24fb93ce96947b18 drivers: use req op accessor

:: TO: Mike Christie 
:: CC: 0day robot 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-06-05 Thread kbuild test robot
Hi,

[auto build test ERROR on v4.7-rc1]
[cannot apply to dm/for-next md/for-next next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/mchristi-redhat-com/v8-separate-operations-from-flags-in-the-bio-request-structs/20160606-040240
config: m32r-opsput_defconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

>> ERROR: "__ucmpdi2" [drivers/scsi/sd_mod.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-06-05 Thread kbuild test robot
Hi,

[auto build test WARNING on v4.7-rc1]
[cannot apply to dm/for-next md/for-next next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/mchristi-redhat-com/v8-separate-operations-from-flags-in-the-bio-request-structs/20160606-040240
config: x86_64-randconfig-i0-201623 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/genhd.h:67:0,
from include/linux/blkdev.h:9,
from fs/ext4/ext4.h:20,
from fs/ext4/ext4_extents.h:22,
from fs/ext4/crypto.c:37:
   fs/ext4/crypto.c: In function 'ext4_encrypted_zeroout':
>> include/linux/fs.h:197:19: warning: passing argument 1 of 'submit_bio_wait' 
>> makes pointer from integer without a cast [-Wint-conversion]
#define RW_MASK   REQ_OP_WRITE
  ^
   include/linux/fs.h:201:17: note: in expansion of macro 'RW_MASK'
#define WRITE   RW_MASK
^~~
   fs/ext4/crypto.c:442:25: note: in expansion of macro 'WRITE'
  err = submit_bio_wait(WRITE, bio);
^
   In file included from include/linux/blkdev.h:19:0,
from fs/ext4/ext4.h:20,
from fs/ext4/ext4_extents.h:22,
from fs/ext4/crypto.c:37:
   include/linux/bio.h:471:12: note: expected 'struct bio *' but argument is of 
type 'int'
extern int submit_bio_wait(struct bio *bio);
   ^~~
   fs/ext4/crypto.c:442:9: error: too many arguments to function 
'submit_bio_wait'
  err = submit_bio_wait(WRITE, bio);
^~~
   In file included from include/linux/blkdev.h:19:0,
from fs/ext4/ext4.h:20,
from fs/ext4/ext4_extents.h:22,
from fs/ext4/crypto.c:37:
   include/linux/bio.h:471:12: note: declared here
extern int submit_bio_wait(struct bio *bio);
   ^~~

vim +/submit_bio_wait +197 include/linux/fs.h

   181   * READAUsed for read-ahead operations. Lower priority, 
and the
   182   *  block layer could (in theory) choose to ignore 
this
   183   *  request if it runs into resource problems.
   184   * WRITEA normal async write. Device will be plugged.
   185   * WRITE_SYNC   Synchronous write. Identical to WRITE, but 
passes down
   186   *  the hint that someone will be waiting on this IO
   187   *  shortly. The write equivalent of READ_SYNC.
   188   * WRITE_ODIRECTSpecial case write for O_DIRECT only.
   189   * WRITE_FLUSH  Like WRITE_SYNC but with preceding cache flush.
   190   * WRITE_FUALike WRITE_SYNC but data is guaranteed to be on
   191   *  non-volatile media on completion.
   192   * WRITE_FLUSH_FUA  Combination of WRITE_FLUSH and FUA. The IO is 
preceded
   193   *  by a cache flush and data is guaranteed to be on
   194   *  non-volatile media on completion.
   195   *
   196   */
 > 197  #define RW_MASK REQ_OP_WRITE
   198  #define RWA_MASKREQ_RAHEAD
   199  
   200  #define READREQ_OP_READ
   201  #define WRITE   RW_MASK
   202  #define READA   RWA_MASK
   203  
   204  #define READ_SYNC   REQ_SYNC
   205  #define WRITE_SYNC  (REQ_SYNC | REQ_NOIDLE)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code

2016-06-05 Thread mchristi
From: Mike Christie 

This patch drops the compat definition of req_op where it matches
the rq_flag_bits definitions, and drops the related old and compat
code that allowed users to set either the op or flags for the operation.

We also then store the operation in the bi_rw/cmd_flags field similar
to how we used to store the bio ioprio where it sat in the upper bits
of the field.

Signed-off-by: Mike Christie 
---
 drivers/scsi/sd.c   |  2 +-
 include/linux/bio.h |  3 ---
 include/linux/blk_types.h   | 52 +
 include/linux/blkdev.h  | 14 
 include/linux/fs.h  | 37 +---
 include/trace/events/f2fs.h |  1 -
 6 files changed, 46 insertions(+), 63 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c8dc221..fad86ad 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1012,7 +1012,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd 
*SCpnt)
} else if (rq_data_dir(rq) == READ) {
SCpnt->cmnd[0] = READ_6;
} else {
-   scmd_printk(KERN_ERR, SCpnt, "Unknown command %d,%llx\n",
+   scmd_printk(KERN_ERR, SCpnt, "Unknown command %llu,%llx\n",
req_op(rq), (unsigned long long) rq->cmd_flags);
goto out;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 35108c2..0bbb2e3 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -44,9 +44,6 @@
 #define BIO_MAX_SIZE   (BIO_MAX_PAGES << PAGE_SHIFT)
 #define BIO_MAX_SECTORS(BIO_MAX_SIZE >> 9)
 
-#define bio_op(bio)(op_from_rq_bits((bio)->bi_rw))
-#define bio_set_op_attrs(bio, op, flags)   ((bio)->bi_rw |= (op | flags))
-
 #define bio_prio(bio)  (bio)->bi_ioprio
 #define bio_set_prio(bio, prio)((bio)->bi_ioprio = prio)
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 5efb6f1..23c1ab2 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -48,7 +48,9 @@ struct bio {
struct block_device *bi_bdev;
unsigned intbi_flags;   /* status, command, etc */
int bi_error;
-   unsigned intbi_rw;  /* READ/WRITE */
+   unsigned intbi_rw;  /* bottom bits req flags,
+* top bits REQ_OP
+*/
unsigned short  bi_ioprio;
 
struct bvec_iterbi_iter;
@@ -106,6 +108,16 @@ struct bio {
struct bio_vec  bi_inline_vecs[0];
 };
 
+#define BIO_OP_SHIFT   (8 * sizeof(unsigned int) - REQ_OP_BITS)
+#define bio_op(bio)((bio)->bi_rw >> BIO_OP_SHIFT)
+
+#define bio_set_op_attrs(bio, op, op_flags) do {   \
+   WARN_ON(op >= (1 << REQ_OP_BITS));  \
+   (bio)->bi_rw &= ((1 << BIO_OP_SHIFT) - 1);  \
+   (bio)->bi_rw |= ((unsigned int) (op) << BIO_OP_SHIFT);  \
+   (bio)->bi_rw |= op_flags;   \
+} while (0)
+
 #define BIO_RESET_BYTESoffsetof(struct bio, bi_max_vecs)
 
 /*
@@ -144,7 +156,6 @@ struct bio {
  */
 enum rq_flag_bits {
/* common flags */
-   __REQ_WRITE,/* not set, read. set, write */
__REQ_FAILFAST_DEV, /* no driver retries of device errors */
__REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
__REQ_FAILFAST_DRIVER,  /* no driver retries of driver errors */
@@ -152,9 +163,7 @@ enum rq_flag_bits {
__REQ_SYNC, /* request is sync (sync write or read) */
__REQ_META, /* metadata io request */
__REQ_PRIO, /* boost priority in cfq */
-   __REQ_DISCARD,  /* request to discard sectors */
-   __REQ_SECURE,   /* secure discard (used with __REQ_DISCARD) */
-   __REQ_WRITE_SAME,   /* write same block many times */
+   __REQ_SECURE,   /* secure discard (used with REQ_OP_DISCARD) */
 
__REQ_NOIDLE,   /* don't anticipate more IO after this one */
__REQ_INTEGRITY,/* I/O includes block integrity payload */
@@ -190,28 +199,22 @@ enum rq_flag_bits {
__REQ_NR_BITS,  /* stops here */
 };
 
-#define REQ_WRITE  (1ULL << __REQ_WRITE)
 #define REQ_FAILFAST_DEV   (1ULL << __REQ_FAILFAST_DEV)
 #define REQ_FAILFAST_TRANSPORT (1ULL << __REQ_FAILFAST_TRANSPORT)
 #define REQ_FAILFAST_DRIVER(1ULL << __REQ_FAILFAST_DRIVER)
 #define REQ_SYNC   (1ULL << __REQ_SYNC)
 #define REQ_META   (1ULL << __REQ_META)
 #define REQ_PRIO   (1ULL << __REQ_PRIO)
-#define REQ_DISCARD(1ULL << __REQ_DISCARD)
-#define REQ_WRITE_SAME (1ULL << __REQ_WRITE_SAME)
 #define REQ_NOIDLE (1ULL << __REQ_NOIDLE)
 #define REQ_