[PATCH] block/loop: Don't hold lock while rereading partition.

2018-09-24 Thread Tetsuo Handa
syzbot is reporting circular locking dependency between bdev->bd_mutex and lo->lo_ctl_mutex [1] which is caused by calling blkdev_reread_part() with lock held. Don't hold loop_ctl_mutex while calling blkdev_reread_part(). Also, bring bdgrab() at loop_set_fd() to before loop_reread_partitions() in

[PATCH v2] block/loop: Use global lock for ioctl() operation.

2018-09-24 Thread Tetsuo Handa
syzbot is reporting NULL pointer dereference [1] which is caused by race condition between ioctl(loop_fd, LOOP_CLR_FD, 0) versus ioctl(other_loop_fd, LOOP_SET_FD, loop_fd) due to traversing other loop devices at loop_validate_file() without holding corresponding lo->lo_ctl_mutex locks. Since

[PATCH] block/loop: Use global lock for ioctl() operation.

2018-09-24 Thread Tetsuo Handa
syzbot is reporting NULL pointer dereference [1] which is caused by race condition between ioctl(loop_fd, LOOP_CLR_FD, 0) versus ioctl(other_loop_fd, LOOP_SET_FD, loop_fd) due to traversing other loop devices at loop_validate_file() without holding corresponding lo->lo_ctl_mutex locks. Since

[PATCH] block/loop: Don't grab "struct file" for vfs_getattr() operation.

2018-09-24 Thread Tetsuo Handa
vfs_getattr() needs "struct path" rather than "struct file". Let's use path_get()/path_put() rather than get_file()/fput(). Signed-off-by: Tetsuo Handa --- drivers/block/loop.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/loop.c

Re: [PATCH] blk-mq: Allow blocking queue tag iter callbacks

2018-09-24 Thread jianchao.wang
Hi Bart On 09/25/2018 10:20 AM, Bart Van Assche wrote: > On 9/24/18 7:11 PM, jianchao.wang wrote: >> Hi Keith >> >> On 09/25/2018 05:09 AM, Keith Busch wrote: >>> -    /* A deadlock might occur if a request is stuck requiring a >>> - * timeout at the same time a queue freeze is waiting >>> -  

Re: [PATCH] blk-mq: Allow blocking queue tag iter callbacks

2018-09-24 Thread Bart Van Assche
On 9/24/18 7:11 PM, jianchao.wang wrote: Hi Keith On 09/25/2018 05:09 AM, Keith Busch wrote: - /* A deadlock might occur if a request is stuck requiring a -* timeout at the same time a queue freeze is waiting -* completion, since the timeout code would not be able to -

Re: [PATCH] blk-mq: Allow blocking queue tag iter callbacks

2018-09-24 Thread jianchao.wang
Hi Keith On 09/25/2018 05:09 AM, Keith Busch wrote: > - /* A deadlock might occur if a request is stuck requiring a > - * timeout at the same time a queue freeze is waiting > - * completion, since the timeout code would not be able to > - * acquire the queue reference here. > -

Re: clean up physical merging helpers V2

2018-09-24 Thread Ming Lei
On Mon, Sep 24, 2018 at 09:43:45AM +0200, Christoph Hellwig wrote: > Hi Jens, > > this series moves various helpers related to merging based on physical > addresses from the public headers into block/, cleans up the code a bit > and removes not nessecary includes from the block headers. > >

[PATCH] blk-mq: Allow blocking queue tag iter callbacks

2018-09-24 Thread Keith Busch
A recent commit had tag iterator callbacks run under the rcu read lock. Existing callbacks exist that do not satisy the rcu non-blocking requirement. The commit intended to prevent an iterator from accessing a queue that's being modified. This patch fixes the original issue by taking a queue

Re: [PATCH v4] block/loop: Serialize ioctl operations.

2018-09-24 Thread Tetsuo Handa
On 2018/09/25 3:47, Jan Kara wrote: >> +/* >> + * unlock_loop - Unlock loop_mutex as needed. >> + * >> + * Explicitly call this function before calling fput() or >> blkdev_reread_part() >> + * in order to avoid circular lock dependency. After this function is >> called, >> + * current thread is

Re: [PATCH v10 5/8] percpu-refcount: Introduce percpu_ref_resurrect()

2018-09-24 Thread Bart Van Assche
On Mon, 2018-09-24 at 11:01 -0700, Tejun Heo wrote: > Hello, Bart. > > On Fri, Sep 21, 2018 at 01:31:19PM -0700, Bart Van Assche wrote: > > +void percpu_ref_resurrect(struct percpu_ref *ref) > > +{ > > + unsigned long __percpu *percpu_count; > > unsigned long flags; > > > >

Re: Regression caused by f5bbbbe4d635

2018-09-24 Thread Keith Busch
On Mon, Sep 24, 2018 at 12:51:07PM -0700, Bart Van Assche wrote: > On Mon, 2018-09-24 at 13:13 -0600, Keith Busch wrote: > > diff --git a/block/blk-mq.c b/block/blk-mq.c > > index 85a1c1a59c72..28d128450621 100644 > > --- a/block/blk-mq.c > > +++ b/block/blk-mq.c > > @@ -848,22 +848,6 @@ static

Re: Regression caused by f5bbbbe4d635

2018-09-24 Thread Bart Van Assche
On Mon, 2018-09-24 at 13:13 -0600, Keith Busch wrote: > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 85a1c1a59c72..28d128450621 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -848,22 +848,6 @@ static void blk_mq_timeout_work(struct work_struct *work) > struct blk_mq_hw_ctx

Re: Regression caused by f5bbbbe4d635

2018-09-24 Thread Keith Busch
On Mon, Sep 24, 2018 at 12:44:13PM -0600, Jens Axboe wrote: > Hi, > > This commit introduced a rcu_read_lock() inside > blk_mq_queue_tag_busy_iter() - this is problematic for the timout code, > since we now end up holding the RCU read lock over the timeout code. As > just one example, nvme ends

Regression caused by f5bbbbe4d635

2018-09-24 Thread Jens Axboe
Hi, This commit introduced a rcu_read_lock() inside blk_mq_queue_tag_busy_iter() - this is problematic for the timout code, since we now end up holding the RCU read lock over the timeout code. As just one example, nvme ends up doing: nvme_timeout() nvme_dev_disable()

Re: clean up physical merging helpers V2

2018-09-24 Thread Jens Axboe
On 9/24/18 1:43 AM, Christoph Hellwig wrote: > Hi Jens, > > this series moves various helpers related to merging based on physical > addresses from the public headers into block/, cleans up the code a bit > and removes not nessecary includes from the block headers. > > Change since V1: > -

Re: [PATCH v10 5/8] percpu-refcount: Introduce percpu_ref_resurrect()

2018-09-24 Thread Tejun Heo
Hello, Bart. On Fri, Sep 21, 2018 at 01:31:19PM -0700, Bart Van Assche wrote: > +void percpu_ref_resurrect(struct percpu_ref *ref) > +{ > + unsigned long __percpu *percpu_count; > unsigned long flags; > > spin_lock_irqsave(_ref_switch_lock, flags); > > -

Re: [PATCH] block: use nanosecond resolution for iostat

2018-09-24 Thread Omar Sandoval
On Fri, Sep 21, 2018 at 08:27:17PM -0600, Jens Axboe wrote: > On 9/21/18 5:44 PM, Omar Sandoval wrote: > > From: Omar Sandoval > > > > Klaus Kusche reported that the I/O busy time in /proc/diskstats was not > > updating properly on 4.18. This is because we started using ktime to > > track

[PATCH 08/10] block: remove bvec_to_phys

2018-09-24 Thread Christoph Hellwig
We only use it in biovec_phys_mergeable and a m68k paravirt driver, so just opencode it there. Also remove the pointless unsigned long cast for the offset in the opencoded instances. Signed-off-by: Christoph Hellwig Reviewed-by: Geert Uytterhoeven --- arch/m68k/emu/nfblock.c | 2 +-

[PATCH 06/10] block: add a missing BIOVEC_SEG_BOUNDARY check in bio_add_pc_page

2018-09-24 Thread Christoph Hellwig
The actual recaculation of segments in __blk_recalc_rq_segments will do this check, so there is no point in forcing it if we know it won't succeed. Signed-off-by: Christoph Hellwig --- block/bio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c

[PATCH 05/10] block: simplify BIOVEC_PHYS_MERGEABLE

2018-09-24 Thread Christoph Hellwig
Turn the macro into an inline, move it to blk.h and simplify the arch hooks a bit. Also rename the function to biovec_phys_mergeable as there is no need to shout. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/io.h | 5 ++--- arch/arm64/include/asm/io.h | 5 ++---

[PATCH 10/10] block: don't include bug.h from bio.h

2018-09-24 Thread Christoph Hellwig
No need to pull in the BUG() defintion. Signed-off-by: Christoph Hellwig --- include/linux/bio.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index b3d47862b1b4..f447b0ebb288 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -21,7

[PATCH 09/10] block: don't include io.h from bio.h

2018-09-24 Thread Christoph Hellwig
Now that we don't need an override for BIOVEC_PHYS_MERGEABLE there is no need to drag this header in. Signed-off-by: Christoph Hellwig --- include/linux/bio.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 9ad4b0a487a4..b3d47862b1b4 100644

[PATCH 03/10] block: move req_gap_{back,front}_merge to blk-merge.c

2018-09-24 Thread Christoph Hellwig
Keep it close to the actual users instead of exposing the function to all drivers. Signed-off-by: Christoph Hellwig --- block/blk-merge.c | 65 +++ include/linux/blkdev.h | 69 -- 2 files changed, 65 insertions(+),

[PATCH 04/10] block: move req_gap_back_merge to blk.h

2018-09-24 Thread Christoph Hellwig
No need to expose these helpers outside the block layer. Signed-off-by: Christoph Hellwig --- block/blk.h| 19 +++ include/linux/blkdev.h | 19 --- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/block/blk.h b/block/blk.h index

[PATCH 07/10] block: merge BIOVEC_SEG_BOUNDARY into biovec_phys_mergeable

2018-09-24 Thread Christoph Hellwig
These two checks should always be performed together, so merge them into a single helper. Signed-off-by: Christoph Hellwig --- block/bio.c | 4 +--- block/blk-integrity.c | 12 ++-- block/blk-merge.c | 29 + block/blk.h | 12

[PATCH 01/10] arm: remove the unused BIOVEC_MERGEABLE define

2018-09-24 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/io.h | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 2cfbc531f63b..6774553dc214 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -459,13 +459,6

[PATCH 02/10] block: move integrity_req_gap_{back,front}_merge to blk.h

2018-09-24 Thread Christoph Hellwig
No need to expose these to drivers. Signed-off-by: Christoph Hellwig --- block/blk.h| 35 +-- include/linux/blkdev.h | 31 --- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/block/blk.h b/block/blk.h index

clean up physical merging helpers V2

2018-09-24 Thread Christoph Hellwig
Hi Jens, this series moves various helpers related to merging based on physical addresses from the public headers into block/, cleans up the code a bit and removes not nessecary includes from the block headers. Change since V1: - dropped the Xen related changed which are moved into a new series