* Re: split scsi passthrough fields out of struct request V2
From: Bart Van Assche @ 2017-02-03 0:20 UTC (permalink / raw)
To: snitzer@redhat.com; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <20170202211014.GA27604@redhat.com>
On Thu, 2017-02-02 at 16:10 -0500, Mike Snitzer wrote:
> Care to try moving the dm_get(md) at the end of dm_start_request() to
> the beginning of dm_start_request() and report back on whether it helps
> at all?
Hello Mike,
Sorry but I don't see how that could make a difference. While we are at it:
since dm_start_request() calls dm_get() and since rq_completed() calls
dm_put(), calls to these two functions should always be paired. There is
only one dm_start_request() call in the dm-mq code, namely the one in
dm_mq_queue_rq(). However, if map_request() returns DM_MAPIO_REQUEUE then
rq_completed() is called twice: a first time by
dm_requeue_original_request() and a second time by the dm_mq_queue_rq().
Do you agree with this?
Thanks,
Bart.=
^ permalink raw reply
* Re: [PATCH] blk-mq-sched: bypass the scheduler for flushes entirely
From: Jens Axboe @ 2017-02-02 23:57 UTC (permalink / raw)
To: Omar Sandoval, linux-block; +Cc: kernel-team
In-Reply-To: <0d437b20c5eafb38997dbb4695c6387cbe18991a.1486078616.git.osandov@fb.com>
On 02/02/2017 04:42 PM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> There's a weird inconsistency that flushes are mostly hidden from the
> scheduler, but it needs to be aware of them in ->insert_requests().
> Instead of having every scheduler call blk_mq_sched_bypass_insert(),
> let's do it in the common framework.
Thanks Omar, looks good to me. After a cycle or two, we can kill
the debug loop in blk_mq_sched_insert_requests().
--
Jens Axboe
^ permalink raw reply
* Re: block for-next: zram build error
From: Jens Axboe @ 2017-02-02 23:56 UTC (permalink / raw)
To: Bart Van Assche; +Cc: linux-block@vger.kernel.org, Jan Kara
In-Reply-To: <1486078839.2816.24.camel@sandisk.com>
On 02/02/2017 04:40 PM, Bart Van Assche wrote:
> Hello Jens,
>
> I noticed accidentally that with the for-next branch of the block
> git repository that the zram driver doesn't build anymore:
>
>
> $ make M=drivers/block/zram
> LD drivers/block/zram/built-in.o
> CC [M] drivers/block/zram/zcomp.o
> CC [M] drivers/block/zram/zram_drv.o
> drivers/block/zram/zram_drv.c: In function ‘zram_revalidate_disk’:
> drivers/block/zram/zram_drv.c:120:37: error: ‘zram->disk->queue->backing_dev_info’ is a pointer; did you mean to use ‘->’?
> zram->disk->queue->backing_dev_info.capabilities |=
> ^
> ->
> make[1]: *** [scripts/Makefile.build:294: drivers/block/zram/zram_drv.o] Error 1
> make: *** [Makefile:1490: _module_drivers/block/zram] Error 2
>
> Compilation exited abnormally with code 2 at Thu Feb 2 15:37:19
>
>
> I have not yet tried to figure out which commit broke the build.
Thanks for catching that, Bart. I fixed it here after your report:
http://git.kernel.dk/cgit/linux-block/commit/?h=for-4.11/next&id=e17354961bb50931ec7b33f59c0713dcf98ac7d2
It's caused by commit:
commit dc3b17cc8bf21307c7e076e7c778d5db756f7871
Author: Jan Kara <jack@suse.cz>
Date: Thu Feb 2 15:56:50 2017 +0100
block: Use pointer to backing_dev_info from request_queue
--
Jens Axboe
^ permalink raw reply
* block for-next: zram build error
From: Bart Van Assche @ 2017-02-02 23:40 UTC (permalink / raw)
To: axboe@fb.com; +Cc: linux-block@vger.kernel.org
SGVsbG8gSmVucywNCg0KSSBub3RpY2VkIGFjY2lkZW50YWxseSB0aGF0IHdpdGggdGhlIGZvci1u
ZXh0IGJyYW5jaCBvZiB0aGUgYmxvY2sNCmdpdCByZXBvc2l0b3J5IHRoYXQgdGhlIHpyYW0gZHJp
dmVyIGRvZXNuJ3QgYnVpbGQgYW55bW9yZToNCg0KDQokIG1ha2UgTT1kcml2ZXJzL2Jsb2NrL3py
YW0NCsKgIExEwqDCoMKgwqDCoMKgZHJpdmVycy9ibG9jay96cmFtL2J1aWx0LWluLm8NCsKgIEND
IFtNXcKgwqBkcml2ZXJzL2Jsb2NrL3pyYW0vemNvbXAubw0KwqAgQ0MgW01dwqDCoGRyaXZlcnMv
YmxvY2svenJhbS96cmFtX2Rydi5vDQpkcml2ZXJzL2Jsb2NrL3pyYW0venJhbV9kcnYuYzogSW4g
ZnVuY3Rpb24g4oCYenJhbV9yZXZhbGlkYXRlX2Rpc2vigJk6DQpkcml2ZXJzL2Jsb2NrL3pyYW0v
enJhbV9kcnYuYzoxMjA6Mzc6IGVycm9yOiDigJh6cmFtLT5kaXNrLT5xdWV1ZS0+YmFja2luZ19k
ZXZfaW5mb+KAmSBpcyBhIHBvaW50ZXI7IGRpZCB5b3UgbWVhbiB0byB1c2Ug4oCYLT7igJk/DQrC
oCB6cmFtLT5kaXNrLT5xdWV1ZS0+YmFja2luZ19kZXZfaW5mby5jYXBhYmlsaXRpZXMgfD0NCsKg
wqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgXg0KwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqAtPg0KbWFrZVsxXTogKioqIFtzY3Jp
cHRzL01ha2VmaWxlLmJ1aWxkOjI5NDogZHJpdmVycy9ibG9jay96cmFtL3pyYW1fZHJ2Lm9dIEVy
cm9yIDENCm1ha2U6ICoqKiBbTWFrZWZpbGU6MTQ5MDogX21vZHVsZV9kcml2ZXJzL2Jsb2NrL3py
YW1dIEVycm9yIDINCg0KQ29tcGlsYXRpb24gZXhpdGVkIGFibm9ybWFsbHkgd2l0aCBjb2RlIDIg
YXQgVGh1IEZlYsKgwqAyIDE1OjM3OjE5DQoNCg0KSSBoYXZlIG5vdCB5ZXQgdHJpZWQgdG8gZmln
dXJlIG91dCB3aGljaCBjb21taXQgYnJva2UgdGhlIGJ1aWxkLg0KDQpCYXJ0Lg==
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Bart Van Assche @ 2017-02-02 22:38 UTC (permalink / raw)
To: snitzer@redhat.com; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <20170202210434.GA27548@redhat.com>
On Thu, 2017-02-02 at 16:04 -0500, Mike Snitzer wrote:
> Any progress on getting this to work without requiring infiniband HW?
Hello Mike,
Intructions for running these tests over SoftRoCE have been added to
the README.md file in https://github.com/bvanassche/srp-test. However,
I'm not sure the SoftRoCE driver is already stable enough to run these
tests on top of that driver.
Bart.=
^ permalink raw reply
* Re: [PATCH 7/8] mq-deadline: add blk-mq adaptation of the deadline IO scheduler
From: Jens Axboe @ 2017-02-02 21:32 UTC (permalink / raw)
To: Paolo Valente; +Cc: Jens Axboe, linux-block, Linux-Kernal, osandov
In-Reply-To: <6958F4D4-84EF-413B-9C40-E16E0A711B87@linaro.org>
On 02/02/2017 02:15 PM, Paolo Valente wrote:
>
>> Il giorno 02 feb 2017, alle ore 16:30, Jens Axboe <axboe@fb.com> ha scritto:
>>
>> On 02/02/2017 02:19 AM, Paolo Valente wrote:
>>> The scheme is clear. One comment, in case it could make sense and
>>> avoid more complexity: since put_rq_priv is invoked in two different
>>> contexts, process or interrupt, I didn't feel so confusing that, when
>>> put_rq_priv is invoked in the context where the lock cannot be held
>>> (unless one is willing to pay with irq disabling all the times), the
>>> lock is not held, while, when invoked in the context where the lock
>>> can be held, the lock is actually held, or must be taken.
>>
>> If you grab the same lock from put_rq_priv, yes, you must make it IRQ
>> disabling in all contexts, and use _irqsave() from put_rq_priv. If it's
>> just freeing resources, you could potentially wait and do that when
>> someone else needs them, since that part will come from proces context.
>> That would need two locks, though.
>>
>> As I said above, I would not worry about the IRQ disabling lock.
>>
>
> I'm sorry, I focused only on the IRQ-disabling consequence of grabbing
> a scheduler lock also in IRQ context. I thought it was a serious
> enough issue to avoid this option. Yet there is also a deadlock
> problem related to this option. In fact, the IRQ handler may preempt
> some process-context code that already holds some other locks, and, if
> some of these locks are already held by another process, which is
> executing on another CPU and which then tries to take the scheduler
> lock, or which happens to be preempted by an IRQ handler trying to
> grab the scheduler lock, then a deadlock occurs. This is not just a
> speculation, but a problem that did occur before I moved to a
> deferred-work solution, and that can be readily reproduced. Before
> moving to a deferred work solution, I tried various code manipulations
> to avoid these deadlocks without resorting to deferred work, but at no
> avail.
There are two important rules here:
1) If a lock is ever used in interrupt context, anyone acquiring it must
ensure that interrupts gets disabled.
2) If multiple locks are needed, they need to be acquired in the right
order.
Instead of talking in hypotheticals, be more specific. With the latest
code, the scheduler lock should now be fine, there should be no cases
where you are being invoked with it held. I'm assuming you are running
with lockdep enabled on your kernel? Post the stack traces from your
problem (and your code...), then we can take a look.
Don't punt to deferring work from your put_rq_private() function, that's
a suboptimal work around. It needs to be fixed for real.
> At any rate, bfq seems now to work, so I can finally move from just
> asking questions endlessly, to proposing actual code to discuss on.
> I'm about to: port this version of bfq to your improved/fixed
> blk-mq-sched version in for-4.11 (port postponed, to avoid introducing
> further changes in code that did not yet wok), run more extensive
> tests, polish commits a little bit, and finally share a branch.
Post the code sooner rather than later. There are bound to be things
that need to be improved or fixed up, let's start this process now. The
framework is pretty much buttoned up at this point, so there's time to
shift the attention a bit to a consumer of it.
--
Jens Axboe
^ permalink raw reply
* Re: [PATCH 7/8] mq-deadline: add blk-mq adaptation of the deadline IO scheduler
From: Paolo Valente @ 2017-02-02 21:15 UTC (permalink / raw)
To: Jens Axboe; +Cc: Jens Axboe, linux-block, Linux-Kernal, osandov
In-Reply-To: <f26b60aa-b047-d7a3-550d-5270c696e2a1@fb.com>
> Il giorno 02 feb 2017, alle ore 16:30, Jens Axboe <axboe@fb.com> ha =
scritto:
>=20
> On 02/02/2017 02:19 AM, Paolo Valente wrote:
>> The scheme is clear. One comment, in case it could make sense and
>> avoid more complexity: since put_rq_priv is invoked in two different
>> contexts, process or interrupt, I didn't feel so confusing that, when
>> put_rq_priv is invoked in the context where the lock cannot be held
>> (unless one is willing to pay with irq disabling all the times), the
>> lock is not held, while, when invoked in the context where the lock
>> can be held, the lock is actually held, or must be taken.
>=20
> If you grab the same lock from put_rq_priv, yes, you must make it IRQ
> disabling in all contexts, and use _irqsave() from put_rq_priv. If =
it's
> just freeing resources, you could potentially wait and do that when
> someone else needs them, since that part will come from proces =
context.
> That would need two locks, though.
>=20
> As I said above, I would not worry about the IRQ disabling lock.
>=20
I'm sorry, I focused only on the IRQ-disabling consequence of grabbing
a scheduler lock also in IRQ context. I thought it was a serious
enough issue to avoid this option. Yet there is also a deadlock
problem related to this option. In fact, the IRQ handler may preempt
some process-context code that already holds some other locks, and, if
some of these locks are already held by another process, which is
executing on another CPU and which then tries to take the scheduler
lock, or which happens to be preempted by an IRQ handler trying to
grab the scheduler lock, then a deadlock occurs. This is not just a
speculation, but a problem that did occur before I moved to a
deferred-work solution, and that can be readily reproduced. Before
moving to a deferred work solution, I tried various code manipulations
to avoid these deadlocks without resorting to deferred work, but at no
avail.
At any rate, bfq seems now to work, so I can finally move from just
asking questions endlessly, to proposing actual code to discuss on.
I'm about to: port this version of bfq to your improved/fixed
blk-mq-sched version in for-4.11 (port postponed, to avoid introducing
further changes in code that did not yet wok), run more extensive
tests, polish commits a little bit, and finally share a branch.
Thanks,
Paolo
> --=20
> Jens Axboe
>=20
> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" =
in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Mike Snitzer @ 2017-02-02 21:10 UTC (permalink / raw)
To: Bart Van Assche; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <20170202210434.GA27548@redhat.com>
On Thu, Feb 02 2017 at 4:04pm -0500,
Mike Snitzer <snitzer@redhat.com> wrote:
> On Thu, Feb 02 2017 at 2:46pm -0500,
> Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
>
> > On Thu, 2017-02-02 at 14:13 -0500, Mike Snitzer wrote:
> > > On Thu, Feb 02 2017 at 1:43pm -0500, Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
> > > > On Thu, 2017-02-02 at 13:33 -0500, Mike Snitzer wrote:
> > > > > I'll go back over hch's changes to see if I can spot anything. But is
> > > > > this testing using dm_mod.use_bk_mq=Y or are you testing old .request_fn
> > > > > dm-multipath?
> > > >
> > > > The srp-test software tests multiple configurations: dm-mq on scsi-mq, dm-sq
> > > > on scsi-mq and dm-sq on scsi-sq. I have not yet checked which of these
> > > > three configurations triggers the kernel crash.
> > >
> > > OK, such info is important to provide for crashes like this. Please let
> > > me know once you do.
> >
> > Hello Mike,
> >
> > Apparently it's the large I/O test (using dm-mq on scsi-mq) that triggers the
> > crash:
>
> I've gone over Christoph's "dm: always defer request allocation to the
> owner of the request_queue" commit yet again. Most of that commit's
> changes are just mechanical. I didn't see any problems.
>
> In general, dm_start_request() calls dm_get(md) to take a reference on
> the mapped_device. And rq_completed() calls dm_put(md) to drop the
> reference. The DM device's request_queue (md->queue) should _not_ ever
> be torn down before all references on the md have been dropped. But I'll
> have to look closer on how/if that is enforced anywhere by coordinating
> with block core.
>
> In any case, the crash you reported was that the mapped_device was being
> dereferenced after it was freed (at line 187's md->queue). Which seems
> to imply a dm_get/dm_put reference count regression. But I'm not seeing
> where at this point.
Maybe it isn't a regression but something about Christoph's changes
causes a race to present itself?
Care to try moving the dm_get(md) at the end of dm_start_request() to
the beginning of dm_start_request() and report back on whether it helps
at all?
Thanks,
Mike
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Mike Snitzer @ 2017-02-02 21:04 UTC (permalink / raw)
To: Bart Van Assche; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <1486064795.2816.14.camel@sandisk.com>
On Thu, Feb 02 2017 at 2:46pm -0500,
Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
> On Thu, 2017-02-02 at 14:13 -0500, Mike Snitzer wrote:
> > On Thu, Feb 02 2017 at 1:43pm -0500, Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
> > > On Thu, 2017-02-02 at 13:33 -0500, Mike Snitzer wrote:
> > > > I'll go back over hch's changes to see if I can spot anything. But is
> > > > this testing using dm_mod.use_bk_mq=Y or are you testing old .request_fn
> > > > dm-multipath?
> > >
> > > The srp-test software tests multiple configurations: dm-mq on scsi-mq, dm-sq
> > > on scsi-mq and dm-sq on scsi-sq. I have not yet checked which of these
> > > three configurations triggers the kernel crash.
> >
> > OK, such info is important to provide for crashes like this. Please let
> > me know once you do.
>
> Hello Mike,
>
> Apparently it's the large I/O test (using dm-mq on scsi-mq) that triggers the
> crash:
I've gone over Christoph's "dm: always defer request allocation to the
owner of the request_queue" commit yet again. Most of that commit's
changes are just mechanical. I didn't see any problems.
In general, dm_start_request() calls dm_get(md) to take a reference on
the mapped_device. And rq_completed() calls dm_put(md) to drop the
reference. The DM device's request_queue (md->queue) should _not_ ever
be torn down before all references on the md have been dropped. But I'll
have to look closer on how/if that is enforced anywhere by coordinating
with block core.
In any case, the crash you reported was that the mapped_device was being
dereferenced after it was freed (at line 187's md->queue). Which seems
to imply a dm_get/dm_put reference count regression. But I'm not seeing
where at this point.
> # ~bart/software/infiniband/srp-test/run_tests -r 10
> [ ... ]
> Test /home/bart/software/infiniband/srp-test/tests/02-sq-on-mq succeeded
> Running test /home/bart/software/infiniband/srp-test/tests/03 ...
> Test large transfer sizes with cmd_sg_entries=255
> removing /dev/mapper/mpatht:�[ CRASH ]
>
> The source code of the test I ran is available at
> https://github.com/bvanassche/srp-test.
Any progress on getting this to work without requiring infiniband HW?
^ permalink raw reply
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
From: Richard Weinberger @ 2017-02-02 20:34 UTC (permalink / raw)
To: Jan Kara, linux-fsdevel
Cc: Christoph Hellwig, linux-block, Artem Bityutskiy, Adrian Hunter,
linux-mtd
In-Reply-To: <20170202173422.3240-23-jack@suse.cz>
Jan,
Am 02.02.2017 um 18:34 schrieb Jan Kara:
> Allocate struct backing_dev_info separately instead of embedding it
> inside the superblock. This unifies handling of bdi among users.
>
> CC: Richard Weinberger <richard@nod.at>
> CC: Artem Bityutskiy <dedekind1@gmail.com>
> CC: Adrian Hunter <adrian.hunter@intel.com>
> CC: linux-mtd@lists.infradead.org
> Signed-off-by: Jan Kara <jack@suse.cz>
Is this series available at some git tree, please?
Thanks,
//richard
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Bart Van Assche @ 2017-02-02 19:46 UTC (permalink / raw)
To: snitzer@redhat.com; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <20170202191330.GA27107@redhat.com>
On Thu, 2017-02-02 at 14:13 -0500, Mike Snitzer wrote:
> On Thu, Feb 02 2017 at 1:43pm -0500, Bart Van Assche <Bart.VanAssche@san=
disk.com> wrote:
> > On Thu, 2017-02-02 at 13:33 -0500, Mike Snitzer wrote:
> > > I'll go back over hch's changes to see if I can spot anything. But i=
s
> > > this testing using dm_mod.use_bk_mq=3DY or are you testing old .reque=
st_fn
> > > dm-multipath?
> >=20
> > The srp-test software tests multiple configurations: dm-mq on scsi-mq, =
dm-sq
> > on scsi-mq and dm-sq on scsi-sq. I have not yet checked which of these
> > three configurations triggers the kernel crash.
>=20
> OK, such info is important to provide for crashes like this. Please let
> me know once you do.
Hello Mike,
Apparently it's the large I/O test (using dm-mq on scsi-mq) that triggers t=
he
crash:
# ~bart/software/infiniband/srp-test/run_tests -r 10
[ ... ]
Test /home/bart/software/infiniband/srp-test/tests/02-sq-on-mq succeeded
Running test /home/bart/software/infiniband/srp-test/tests/03 ...
Test large transfer sizes with cmd_sg_entries=3D255
removing /dev/mapper/mpatht:=A0[ CRASH ]
The source code of the test I ran is available at
https://github.com/bvanassche/srp-test.
Bart.=
^ permalink raw reply
* Re: [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems
From: Liu Bo @ 2017-02-02 19:28 UTC (permalink / raw)
To: Jan Kara
Cc: linux-fsdevel, Christoph Hellwig, linux-block, linux-mtd,
linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev,
codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel,
linux-btrfs, v9fs-developer, lustre-devel
In-Reply-To: <20170202173422.3240-5-jack@suse.cz>
Hi,
On Thu, Feb 02, 2017 at 06:34:02PM +0100, Jan Kara wrote:
> Provide helper functions for setting up dynamically allocated
> backing_dev_info structures for filesystems and cleaning them up on
> superblock destruction.
Just one concern, will this cause problems for multiple superblock cases
like nfs with nosharecache?
Thanks,
-liubo
>
> CC: linux-mtd@lists.infradead.org
> CC: linux-nfs@vger.kernel.org
> CC: Petr Vandrovec <petr@vandrovec.name>
> CC: linux-nilfs@vger.kernel.org
> CC: cluster-devel@redhat.com
> CC: osd-dev@open-osd.org
> CC: codalist@coda.cs.cmu.edu
> CC: linux-afs@lists.infradead.org
> CC: ecryptfs@vger.kernel.org
> CC: linux-cifs@vger.kernel.org
> CC: ceph-devel@vger.kernel.org
> CC: linux-btrfs@vger.kernel.org
> CC: v9fs-developer@lists.sourceforge.net
> CC: lustre-devel@lists.lustre.org
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/super.c | 49 ++++++++++++++++++++++++++++++++++++++++
> include/linux/backing-dev-defs.h | 2 +-
> include/linux/fs.h | 6 +++++
> 3 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index ea662b0e5e78..31dc4c6450ef 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb)
> hlist_del_init(&sb->s_instances);
> spin_unlock(&sb_lock);
> up_write(&sb->s_umount);
> + if (sb->s_iflags & SB_I_DYNBDI) {
> + bdi_put(sb->s_bdi);
> + sb->s_bdi = &noop_backing_dev_info;
> + sb->s_iflags &= ~SB_I_DYNBDI;
> + }
> }
>
> EXPORT_SYMBOL(generic_shutdown_super);
> @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
> }
>
> /*
> + * Setup private BDI for given superblock. I gets automatically cleaned up
> + * in generic_shutdown_super().
> + */
> +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
> +{
> + struct backing_dev_info *bdi;
> + int err;
> + va_list args;
> +
> + bdi = bdi_alloc(GFP_KERNEL);
> + if (!bdi)
> + return -ENOMEM;
> +
> + bdi->name = sb->s_type->name;
> +
> + va_start(args, fmt);
> + err = bdi_register_va(bdi, NULL, fmt, args);
> + va_end(args);
> + if (err) {
> + bdi_put(bdi);
> + return err;
> + }
> + WARN_ON(sb->s_bdi != &noop_backing_dev_info);
> + sb->s_bdi = bdi;
> + sb->s_iflags |= SB_I_DYNBDI;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(super_setup_bdi_name);
> +
> +/*
> + * Setup private BDI for given superblock. I gets automatically cleaned up
> + * in generic_shutdown_super().
> + */
> +int super_setup_bdi(struct super_block *sb)
> +{
> + static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
> +
> + return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name,
> + atomic_long_inc_return(&bdi_seq));
> +}
> +EXPORT_SYMBOL(super_setup_bdi);
> +
> +/*
> * This is an internal function, please use sb_end_{write,pagefault,intwrite}
> * instead.
> */
> diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
> index 2ecafc8a2d06..70080b4217f4 100644
> --- a/include/linux/backing-dev-defs.h
> +++ b/include/linux/backing-dev-defs.h
> @@ -143,7 +143,7 @@ struct backing_dev_info {
> congested_fn *congested_fn; /* Function pointer if device is md/dm */
> void *congested_data; /* Pointer to aux data for congested func */
>
> - char *name;
> + const char *name;
>
> struct kref refcnt; /* Reference counter for the structure */
> unsigned int registered:1; /* Is bdi registered? */
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c930cbc19342..8ed8b6d1bc54 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1267,6 +1267,9 @@ struct mm_struct;
> /* sb->s_iflags to limit user namespace mounts */
> #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
>
> +/* Temporary flag until all filesystems are converted to dynamic bdis */
> +#define SB_I_DYNBDI 0x00000100
> +
> /* Possible states of 'frozen' field */
> enum {
> SB_UNFROZEN = 0, /* FS is unfrozen */
> @@ -2103,6 +2106,9 @@ extern int vfs_ustat(dev_t, struct kstatfs *);
> extern int freeze_super(struct super_block *super);
> extern int thaw_super(struct super_block *super);
> extern bool our_mnt(struct vfsmount *mnt);
> +extern __printf(2, 3)
> +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...);
> +extern int super_setup_bdi(struct super_block *sb);
>
> extern int current_umask(void);
>
> --
> 2.10.2
>
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Mike Snitzer @ 2017-02-02 19:13 UTC (permalink / raw)
To: Bart Van Assche; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <1486060991.2816.8.camel@sandisk.com>
On Thu, Feb 02 2017 at 1:43pm -0500,
Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
> On Thu, 2017-02-02 at 13:33 -0500, Mike Snitzer wrote:
> > I'll go back over hch's changes to see if I can spot anything. But is
> > this testing using dm_mod.use_bk_mq=Y or are you testing old .request_fn
> > dm-multipath?
>
> Hello Mike,
>
> The srp-test software tests multiple configurations: dm-mq on scsi-mq, dm-sq
> on scsi-mq and dm-sq on scsi-sq. I have not yet checked which of these
> three configurations triggers the kernel crash.
OK, such info is important to provide for crashes like this. Please let
me know once you do.
Thanks,
Mike
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Bart Van Assche @ 2017-02-02 18:43 UTC (permalink / raw)
To: snitzer@redhat.com; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <20170202183334.GB26910@redhat.com>
On Thu, 2017-02-02 at 13:33 -0500, Mike Snitzer wrote:
> I'll go back over hch's changes to see if I can spot anything. But is
> this testing using dm_mod.use_bk_mq=3DY or are you testing old .request_f=
n
> dm-multipath?
Hello Mike,
The srp-test software tests multiple configurations: dm-mq on scsi-mq, dm-s=
q
on scsi-mq and dm-sq on scsi-sq. I have not yet checked which of these
three configurations triggers the kernel crash.
Bart.=
^ permalink raw reply
* Re: split scsi passthrough fields out of struct request V2
From: Mike Snitzer @ 2017-02-02 18:33 UTC (permalink / raw)
To: Bart Van Assche; +Cc: hch@lst.de, linux-block@vger.kernel.org, axboe@fb.com
In-Reply-To: <1486056424.2816.4.camel@sandisk.com>
On Thu, Feb 02 2017 at 12:27pm -0500,
Bart Van Assche <Bart.VanAssche@sandisk.com> wrote:
> On Wed, 2017-02-01 at 22:01 +0000, Bart Van Assche wrote:
> > However, a new issue shows up sporadically, an issue that I had not yet seen
> > during any test with a kernel tree from Linus:
> >
> > [ 227.613440] general protection fault: 0000 [#1] SMP
> > [ 227.613495] Modules linked in: dm_service_time ib_srp scsi_transport_srp target_core_user uio target_core_pscsi target_core_file ib_srpt target_core_iblock target_core_mod brd netconsole xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat libcrc32c nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter ip_tables x_tables af_packet ib_ipoib msr rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm configfs ib_cm iw_cm mlx4_ib ib_core sb_edac edac_core x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel pcbc tg3 aesni_intel iTCO_wdt mlx4_core ptp iTCO_vendor_support dcdbas aes_x86_64 crypto_simd glue_helper pps_core cryptd pcspkr devlink ipmi_si libphy ipmi_devintf fjes ipmi_msghandler tpm_tis tpm_tis_core lpc_ich mei_me mfd_core mei shpchp wmi tpm button hid_generic usbhid mgag200 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sr_mod sysimgblt fb_sys_fops cdrom ttm drm ehci_pci ehci_hcd usbcore usb_common sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua autofs4
> > [ 227.613774] CPU: 3 PID: 28 Comm: ksoftirqd/3 Not tainted 4.10.0-rc5-dbg+ #1
> > [ 227.613840] Hardware name: Dell Inc. PowerEdge R430/03XKDV, BIOS 1.0.2 11/17/2014
> > [ 227.613893] task: ffff880172a249c0 task.stack: ffffc90001aa8000
> > [ 227.613932] RIP: 0010:rq_completed+0x12/0x90 [dm_mod]
> > [ 227.613965] RSP: 0018:ffffc90001aabda8 EFLAGS: 00010246
> > [ 227.614006] RAX: 0000000000000000 RBX: 6b6b6b6b6b6b6b6b RCX: 0000000000000000
> > [ 227.614043] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 6b6b6b6b6b6b6b6b
> > [ 227.614074] RBP: ffffc90001aabdc0 R08: ffff8803825f4c38 R09: 0000000000000000
> > [ 227.614105] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
> > [ 227.614137] R13: 0000000000000000 R14: ffffffff81c05120 R15: 0000000000000004
> > [ 227.614170] FS: 0000000000000000(0000) GS:ffff88046f2c0000(0000) knlGS:0000000000000000
> > [ 227.614209] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > [ 227.614239] CR2: 0000557e28bc20d0 CR3: 000000038594e000 CR4: 00000000001406e0
> > [ 227.614268] Call Trace:
> > [ 227.614301] dm_softirq_done+0xe6/0x1e0 [dm_mod]
> > [ 227.614337] blk_done_softirq+0x88/0xa0
> > [ 227.614369] __do_softirq+0xba/0x4c0
> > [ 227.614470] run_ksoftirqd+0x1a/0x50
> > [ 227.614499] smpboot_thread_fn+0x123/0x1e0
> > [ 227.614529] kthread+0x107/0x140
> > [ 227.614624] ret_from_fork+0x2e/0x40
> > [ 227.614648] Code: ff ff 31 f6 48 89 c7 e8 cd 0e 2f e1 5d c3 90 66 2e 0f 1f 84 00 00 00 00 00 55 48 63 f6 48 89 e5 41 55 41 89 d5 41 54 53 48 89 fb <4c> 8b a7 88 02 00 00 f0 ff 8c b7 50 03 00 00 e8 ba 43 ff ff 85
> > [ 227.614738] RIP: rq_completed+0x12/0x90 [dm_mod] RSP: ffffc90001aabda8
> >
> > (gdb) list *(rq_completed+0x12)
> > 0xdd12 is in rq_completed (drivers/md/dm-rq.c:187).
> > 182 * the md may be freed in dm_put() at the end of this function.
> > 183 * Or do dm_get() before calling this function and dm_put() later.
> > 184 */
> > 185 static void rq_completed(struct mapped_device *md, int rw, bool run_queue)
> > 186 {
> > 187 struct request_queue *q = md->queue;
> > 188 unsigned long flags;
> > 189
> > 190 atomic_dec(&md->pending[rw]);
> > 191
> >
> > (gdb) disas rq_completed
> > Dump of assembler code for function rq_completed:
> > 0x000000000000dd00 <+0>: push %rbp
> > 0x000000000000dd01 <+1>: movslq %esi,%rsi
> > 0x000000000000dd04 <+4>: mov %rsp,%rbp
> > 0x000000000000dd07 <+7>: push %r13
> > 0x000000000000dd09 <+9>: mov %edx,%r13d
> > 0x000000000000dd0c <+12>: push %r12
> > 0x000000000000dd0e <+14>: push %rbx
> > 0x000000000000dd0f <+15>: mov %rdi,%rbx
> > 0x000000000000dd12 <+18>: mov 0x288(%rdi),%r12
> > 0x000000000000dd19 <+25>: lock decl 0x350(%rdi,%rsi,4)
> >
> > So this was caused by an attempt to dereference %rdi = 0x6b6b6b6b6b6b6b6b.
> > Hence this is probably a use-after-free of struct mapped_device.
>
> Hello Christoph and Mike,
>
> The above crash occurs with Jens' for-next branch but not with Jens'
> for-4.11/block branch. Sorry but I think this means that the SCSI
> passthrough refactoring code is not yet ready for prime time.
I somehow missed your original report from yesterday.
I do agree that this would appear to be a use-after-free; certainly not
a fun bug to sort out.
I'll go back over hch's changes to see if I can spot anything. But is
this testing using dm_mod.use_bk_mq=Y or are you testing old .request_fn
dm-multipath?
Mike
^ permalink raw reply
* [PATCH 21/24] nfs: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, Trond Myklebust,
Anna Schumaker, linux-nfs
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Trond Myklebust <trond.myklebust@primarydata.com>
CC: Anna Schumaker <anna.schumaker@netapp.com>
CC: linux-nfs@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/nfs/client.c | 10 ----------
fs/nfs/internal.h | 6 +++---
fs/nfs/super.c | 34 +++++++++++++++++++---------------
fs/nfs/write.c | 13 ++++++-------
include/linux/nfs_fs_sb.h | 1 -
5 files changed, 28 insertions(+), 36 deletions(-)
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 91a8d610ba0f..479afae529d8 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -738,9 +738,6 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
server->rsize = NFS_MAX_FILE_IO_SIZE;
server->rpages = (server->rsize + PAGE_SIZE - 1) >> PAGE_SHIFT;
- server->backing_dev_info.name = "nfs";
- server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD;
-
if (server->wsize > max_rpc_payload)
server->wsize = max_rpc_payload;
if (server->wsize > NFS_MAX_FILE_IO_SIZE)
@@ -894,12 +891,6 @@ struct nfs_server *nfs_alloc_server(void)
return NULL;
}
- if (bdi_init(&server->backing_dev_info)) {
- nfs_free_iostats(server->io_stats);
- kfree(server);
- return NULL;
- }
-
ida_init(&server->openowner_id);
ida_init(&server->lockowner_id);
pnfs_init_server(server);
@@ -930,7 +921,6 @@ void nfs_free_server(struct nfs_server *server)
ida_destroy(&server->lockowner_id);
ida_destroy(&server->openowner_id);
nfs_free_iostats(server->io_stats);
- bdi_destroy(&server->backing_dev_info);
kfree(server);
nfs_release_automount_timer();
dprintk("<-- nfs_free_server()\n");
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 09ca5095c04e..55591c06b5d0 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -139,7 +139,7 @@ struct nfs_mount_request {
};
struct nfs_mount_info {
- void (*fill_super)(struct super_block *, struct nfs_mount_info *);
+ int (*fill_super)(struct super_block *, struct nfs_mount_info *);
int (*set_security)(struct super_block *, struct dentry *, struct nfs_mount_info *);
struct nfs_parsed_mount_data *parsed;
struct nfs_clone_mount *cloned;
@@ -405,7 +405,7 @@ struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *
struct dentry * nfs_xdev_mount_common(struct file_system_type *, int,
const char *, struct nfs_mount_info *);
void nfs_kill_super(struct super_block *);
-void nfs_fill_super(struct super_block *, struct nfs_mount_info *);
+int nfs_fill_super(struct super_block *, struct nfs_mount_info *);
extern struct rpc_stat nfs_rpcstat;
@@ -456,7 +456,7 @@ extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
/* super.c */
-void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
+int nfs_clone_super(struct super_block *, struct nfs_mount_info *);
void nfs_umount_begin(struct super_block *);
int nfs_statfs(struct dentry *, struct kstatfs *);
int nfs_show_options(struct seq_file *, struct dentry *);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6bca17883b93..16f4d92a96ec 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2322,18 +2322,17 @@ inline void nfs_initialise_sb(struct super_block *sb)
sb->s_blocksize = nfs_block_bits(server->wsize,
&sb->s_blocksize_bits);
- sb->s_bdi = &server->backing_dev_info;
-
nfs_super_set_maxbytes(sb, server->maxfilesize);
}
/*
* Finish setting up an NFS2/3 superblock
*/
-void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
+int nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
{
struct nfs_parsed_mount_data *data = mount_info->parsed;
struct nfs_server *server = NFS_SB(sb);
+ int ret;
sb->s_blocksize_bits = 0;
sb->s_blocksize = 0;
@@ -2351,13 +2350,21 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
}
nfs_initialise_sb(sb);
+
+ ret = super_setup_bdi_name(sb, "%u:%u", MAJOR(server->s_dev),
+ MINOR(server->s_dev));
+ if (ret)
+ return ret;
+ sb->s_bdi->ra_pages = server->rpages * NFS_MAX_READAHEAD;
+ return 0;
+
}
EXPORT_SYMBOL_GPL(nfs_fill_super);
/*
* Finish setting up a cloned NFS2/3/4 superblock
*/
-void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
+int nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
{
const struct super_block *old_sb = mount_info->cloned->sb;
struct nfs_server *server = NFS_SB(sb);
@@ -2377,6 +2384,11 @@ void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
}
nfs_initialise_sb(sb);
+
+ sb->s_bdi = bdi_get(old_sb->s_bdi);
+ sb->s_iflags |= SB_I_DYNBDI;
+
+ return 0;
}
static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
@@ -2529,11 +2541,6 @@ static void nfs_get_cache_cookie(struct super_block *sb,
}
#endif
-static int nfs_bdi_register(struct nfs_server *server)
-{
- return bdi_register_dev(&server->backing_dev_info, server->s_dev);
-}
-
int nfs_set_sb_security(struct super_block *s, struct dentry *mntroot,
struct nfs_mount_info *mount_info)
{
@@ -2601,17 +2608,14 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
nfs_free_server(server);
server = NULL;
} else {
- error = nfs_bdi_register(server);
- if (error) {
- mntroot = ERR_PTR(error);
- goto error_splat_super;
- }
server->super = s;
}
if (!s->s_root) {
/* initial superblock/root creation */
- mount_info->fill_super(s, mount_info);
+ error = mount_info->fill_super(s, mount_info);
+ if (error)
+ goto error_splat_super;
nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index b00d53d13d47..5296c5849a9b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -263,16 +263,15 @@ int nfs_congestion_kb;
static void nfs_set_page_writeback(struct page *page)
{
- struct nfs_server *nfss = NFS_SERVER(page_file_mapping(page)->host);
+ struct inode *inode = page_file_mapping(page)->host;
+ struct nfs_server *nfss = NFS_SERVER(inode);
int ret = test_set_page_writeback(page);
WARN_ON_ONCE(ret != 0);
if (atomic_long_inc_return(&nfss->writeback) >
- NFS_CONGESTION_ON_THRESH) {
- set_bdi_congested(&nfss->backing_dev_info,
- BLK_RW_ASYNC);
- }
+ NFS_CONGESTION_ON_THRESH)
+ set_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
}
static void nfs_end_page_writeback(struct nfs_page *req)
@@ -285,7 +284,7 @@ static void nfs_end_page_writeback(struct nfs_page *req)
end_page_writeback(req->wb_page);
if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH)
- clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC);
+ clear_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
}
@@ -1808,7 +1807,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
}
nfss = NFS_SERVER(data->inode);
if (atomic_long_read(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH)
- clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC);
+ clear_bdi_congested(inode_to_bdi(data->inode), BLK_RW_ASYNC);
nfs_init_cinfo(&cinfo, data->inode, data->dreq);
nfs_commit_end(cinfo.mds);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index b34097c67848..e1502c55741e 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -133,7 +133,6 @@ struct nfs_server {
struct rpc_clnt * client_acl; /* ACL RPC client handle */
struct nlm_host *nlm_host; /* NLM client handle */
struct nfs_iostats __percpu *io_stats; /* I/O statistics */
- struct backing_dev_info backing_dev_info;
atomic_long_t writeback; /* number of writeback pages */
int flags; /* various flags */
unsigned int caps; /* server capabilities */
--
2.10.2
^ permalink raw reply related
* [PATCH 17/24] fuse: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara, Miklos Szeredi
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Miklos Szeredi <miklos@szeredi.hu>
CC: linux-fsdevel@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/fuse/dev.c | 8 ++++----
fs/fuse/fuse_i.h | 3 ---
fs/fuse/inode.c | 42 +++++++++++++-----------------------------
3 files changed, 17 insertions(+), 36 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 70ea57c7b6bb..1912164d57e9 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -382,8 +382,8 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
if (fc->num_background == fc->congestion_threshold &&
fc->connected && fc->bdi_initialized) {
- clear_bdi_congested(&fc->bdi, BLK_RW_SYNC);
- clear_bdi_congested(&fc->bdi, BLK_RW_ASYNC);
+ clear_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC);
+ clear_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC);
}
fc->num_background--;
fc->active_background--;
@@ -570,8 +570,8 @@ void fuse_request_send_background_locked(struct fuse_conn *fc,
fc->blocked = 1;
if (fc->num_background == fc->congestion_threshold &&
fc->bdi_initialized) {
- set_bdi_congested(&fc->bdi, BLK_RW_SYNC);
- set_bdi_congested(&fc->bdi, BLK_RW_ASYNC);
+ set_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC);
+ set_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC);
}
list_add_tail(&req->list, &fc->bg_queue);
flush_bg_queue(fc);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 91307940c8ac..effab9e9607f 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -631,9 +631,6 @@ struct fuse_conn {
/** Negotiated minor version */
unsigned minor;
- /** Backing dev info */
- struct backing_dev_info bdi;
-
/** Entry on the fuse_conn_list */
struct list_head entry;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 6fe6a88ecb4a..90bacbc87fb3 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -386,12 +386,6 @@ static void fuse_send_destroy(struct fuse_conn *fc)
}
}
-static void fuse_bdi_destroy(struct fuse_conn *fc)
-{
- if (fc->bdi_initialized)
- bdi_destroy(&fc->bdi);
-}
-
static void fuse_put_super(struct super_block *sb)
{
struct fuse_conn *fc = get_fuse_conn_super(sb);
@@ -403,7 +397,6 @@ static void fuse_put_super(struct super_block *sb)
list_del(&fc->entry);
fuse_ctl_remove_conn(fc);
mutex_unlock(&fuse_mutex);
- fuse_bdi_destroy(fc);
fuse_conn_put(fc);
}
@@ -928,7 +921,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
fc->no_flock = 1;
}
- fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
+ fc->sb->s_bdi->ra_pages =
+ min(fc->sb->s_bdi->ra_pages, ra_pages);
fc->minor = arg->minor;
fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
fc->max_write = max_t(unsigned, 4096, fc->max_write);
@@ -944,7 +938,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
arg->major = FUSE_KERNEL_VERSION;
arg->minor = FUSE_KERNEL_MINOR_VERSION;
- arg->max_readahead = fc->bdi.ra_pages * PAGE_SIZE;
+ arg->max_readahead = fc->sb->s_bdi->ra_pages * PAGE_SIZE;
arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK |
FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ |
@@ -976,27 +970,20 @@ static void fuse_free_conn(struct fuse_conn *fc)
static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)
{
int err;
+ char *suffix = "";
- fc->bdi.name = "fuse";
- fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_SIZE;
- /* fuse does it's own writeback accounting */
- fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB | BDI_CAP_STRICTLIMIT;
-
- err = bdi_init(&fc->bdi);
+ if (sb->s_bdev)
+ suffix = "-fuseblk";
+ err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev),
+ MINOR(fc->dev), suffix);
if (err)
return err;
- fc->bdi_initialized = 1;
-
- if (sb->s_bdev) {
- err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk",
- MAJOR(fc->dev), MINOR(fc->dev));
- } else {
- err = bdi_register_dev(&fc->bdi, fc->dev);
- }
+ sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_SIZE;
+ /* fuse does it's own writeback accounting */
+ sb->s_bdi->capabilities = BDI_CAP_NO_ACCT_WB | BDI_CAP_STRICTLIMIT;
- if (err)
- return err;
+ fc->bdi_initialized = 1;
/*
* For a single fuse filesystem use max 1% of dirty +
@@ -1010,7 +997,7 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)
*
* /sys/class/bdi/<bdi>/max_ratio
*/
- bdi_set_max_ratio(&fc->bdi, 1);
+ bdi_set_max_ratio(sb->s_bdi, 1);
return 0;
}
@@ -1113,8 +1100,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
if (err)
goto err_dev_free;
- sb->s_bdi = &fc->bdi;
-
/* Handle umasking inside the fuse code */
if (sb->s_flags & MS_POSIXACL)
fc->dont_mask = 1;
@@ -1182,7 +1167,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
err_dev_free:
fuse_dev_free(fud);
err_put_conn:
- fuse_bdi_destroy(fc);
fuse_conn_put(fc);
err_fput:
fput(file);
--
2.10.2
^ permalink raw reply related
* [PATCH 08/24] btrfs: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, Chris Mason,
Josef Bacik, David Sterba, linux-btrfs
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside superblock. This unifies handling of bdi among users.
CC: Chris Mason <clm@fb.com>
CC: Josef Bacik <jbacik@fb.com>
CC: David Sterba <dsterba@suse.com>
CC: linux-btrfs@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/btrfs/ctree.h | 1 -
fs/btrfs/disk-io.c | 36 +++++++-----------------------------
fs/btrfs/super.c | 7 +++++++
3 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6a823719b6c5..1dc06f66dfcf 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -801,7 +801,6 @@ struct btrfs_fs_info {
struct btrfs_super_block *super_for_commit;
struct super_block *sb;
struct inode *btree_inode;
- struct backing_dev_info bdi;
struct mutex tree_log_mutex;
struct mutex transaction_kthread_mutex;
struct mutex cleaner_mutex;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 37a31b12bb0c..b25723e729c0 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1810,21 +1810,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
return ret;
}
-static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
-{
- int err;
-
- err = bdi_setup_and_register(bdi, "btrfs");
- if (err)
- return err;
-
- bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
- bdi->congested_fn = btrfs_congested_fn;
- bdi->congested_data = info;
- bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
- return 0;
-}
-
/*
* called by the kthread helper functions to finally call the bio end_io
* functions. This is where read checksum verification actually happens
@@ -2598,16 +2583,10 @@ int open_ctree(struct super_block *sb,
goto fail;
}
- ret = setup_bdi(fs_info, &fs_info->bdi);
- if (ret) {
- err = ret;
- goto fail_srcu;
- }
-
ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL);
if (ret) {
err = ret;
- goto fail_bdi;
+ goto fail_srcu;
}
fs_info->dirty_metadata_batch = PAGE_SIZE *
(1 + ilog2(nr_cpu_ids));
@@ -2715,7 +2694,6 @@ int open_ctree(struct super_block *sb,
sb->s_blocksize = 4096;
sb->s_blocksize_bits = blksize_bits(4096);
- sb->s_bdi = &fs_info->bdi;
btrfs_init_btree_inode(fs_info);
@@ -2912,9 +2890,12 @@ int open_ctree(struct super_block *sb,
goto fail_sb_buffer;
}
- fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super);
- fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages,
- SZ_4M / PAGE_SIZE);
+ sb->s_bdi->congested_fn = btrfs_congested_fn;
+ sb->s_bdi->congested_data = fs_info;
+ sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
+ sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+ sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
+ sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
sb->s_blocksize = sectorsize;
sb->s_blocksize_bits = blksize_bits(sectorsize);
@@ -3282,8 +3263,6 @@ int open_ctree(struct super_block *sb,
percpu_counter_destroy(&fs_info->delalloc_bytes);
fail_dirty_metadata_bytes:
percpu_counter_destroy(&fs_info->dirty_metadata_bytes);
-fail_bdi:
- bdi_destroy(&fs_info->bdi);
fail_srcu:
cleanup_srcu_struct(&fs_info->subvol_srcu);
fail:
@@ -4010,7 +3989,6 @@ void close_ctree(struct btrfs_fs_info *fs_info)
percpu_counter_destroy(&fs_info->dirty_metadata_bytes);
percpu_counter_destroy(&fs_info->delalloc_bytes);
percpu_counter_destroy(&fs_info->bio_counter);
- bdi_destroy(&fs_info->bdi);
cleanup_srcu_struct(&fs_info->subvol_srcu);
btrfs_free_stripe_hash_table(fs_info);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b5ae7d3d1896..08ef08b63132 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1133,6 +1133,13 @@ static int btrfs_fill_super(struct super_block *sb,
#endif
sb->s_flags |= MS_I_VERSION;
sb->s_iflags |= SB_I_CGROUPWB;
+
+ err = super_setup_bdi(sb);
+ if (err) {
+ btrfs_err(fs_info, "super_setup_bdi failed");
+ return err;
+ }
+
err = open_ctree(sb, fs_devices, (char *)data);
if (err) {
btrfs_err(fs_info, "open_ctree failed");
--
2.10.2
^ permalink raw reply related
* [PATCH 07/24] 9p: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, Eric Van Hensbergen,
Ron Minnich, Latchesar Ionkov, v9fs-developer
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside session. This unifies handling of bdi among users.
CC: Eric Van Hensbergen <ericvh@gmail.com>
CC: Ron Minnich <rminnich@sandia.gov>
CC: Latchesar Ionkov <lucho@ionkov.net>
CC: v9fs-developer@lists.sourceforge.net
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/9p/v9fs.c | 10 +---------
fs/9p/v9fs.h | 1 -
fs/9p/vfs_super.c | 15 ++++++++++++---
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 072e7599583a..0898a1a774fa 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -332,10 +332,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
goto err_names;
init_rwsem(&v9ses->rename_sem);
- rc = bdi_setup_and_register(&v9ses->bdi, "9p");
- if (rc)
- goto err_names;
-
v9ses->uid = INVALID_UID;
v9ses->dfltuid = V9FS_DEFUID;
v9ses->dfltgid = V9FS_DEFGID;
@@ -344,7 +340,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
if (IS_ERR(v9ses->clnt)) {
rc = PTR_ERR(v9ses->clnt);
p9_debug(P9_DEBUG_ERROR, "problem initializing 9p client\n");
- goto err_bdi;
+ goto err_names;
}
v9ses->flags = V9FS_ACCESS_USER;
@@ -414,8 +410,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
err_clnt:
p9_client_destroy(v9ses->clnt);
-err_bdi:
- bdi_destroy(&v9ses->bdi);
err_names:
kfree(v9ses->uname);
kfree(v9ses->aname);
@@ -444,8 +438,6 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
kfree(v9ses->uname);
kfree(v9ses->aname);
- bdi_destroy(&v9ses->bdi);
-
spin_lock(&v9fs_sessionlist_lock);
list_del(&v9ses->slist);
spin_unlock(&v9fs_sessionlist_lock);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 443d12e02043..76eaf49abd3a 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -114,7 +114,6 @@ struct v9fs_session_info {
kuid_t uid; /* if ACCESS_SINGLE, the uid that has access */
struct p9_client *clnt; /* 9p client */
struct list_head slist; /* list of sessions registered with v9fs */
- struct backing_dev_info bdi;
struct rw_semaphore rename_sem;
};
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index de3ed8629196..a0965fb587a5 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -72,10 +72,12 @@ static int v9fs_set_super(struct super_block *s, void *data)
*
*/
-static void
+static int
v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
int flags, void *data)
{
+ int ret;
+
sb->s_maxbytes = MAX_LFS_FILESIZE;
sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
sb->s_blocksize = 1 << sb->s_blocksize_bits;
@@ -85,7 +87,11 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
sb->s_xattr = v9fs_xattr_handlers;
} else
sb->s_op = &v9fs_super_ops;
- sb->s_bdi = &v9ses->bdi;
+
+ ret = super_setup_bdi(sb);
+ if (ret)
+ return ret;
+
if (v9ses->cache)
sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024)/PAGE_SIZE;
@@ -99,6 +105,7 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
#endif
save_mount_options(sb, data);
+ return 0;
}
/**
@@ -138,7 +145,9 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
retval = PTR_ERR(sb);
goto clunk_fid;
}
- v9fs_fill_super(sb, v9ses, flags, data);
+ retval = v9fs_fill_super(sb, v9ses, flags, data);
+ if (retval)
+ goto release_sb;
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
sb->s_d_op = &v9fs_cached_dentry_operations;
--
2.10.2
^ permalink raw reply related
* [PATCH 13/24] orangefs: Remove orangefs_backing_dev_info
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara, Mike Marshall
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
It is not used anywhere.
CC: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/orangefs/inode.c | 6 ------
fs/orangefs/orangefs-kernel.h | 1 -
fs/orangefs/orangefs-mod.c | 12 +-----------
3 files changed, 1 insertion(+), 18 deletions(-)
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 551bc74ed2b8..5cd617980fbf 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -136,12 +136,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb,
return -EINVAL;
}
-struct backing_dev_info orangefs_backing_dev_info = {
- .name = "orangefs",
- .ra_pages = 0,
- .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
-};
-
/** ORANGEFS2 implementation of address space operations */
const struct address_space_operations orangefs_address_operations = {
.readpage = orangefs_readpage,
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 3bf803d732c5..70355a9a2596 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -529,7 +529,6 @@ extern spinlock_t orangefs_htable_ops_in_progress_lock;
extern int hash_table_size;
extern const struct address_space_operations orangefs_address_operations;
-extern struct backing_dev_info orangefs_backing_dev_info;
extern const struct inode_operations orangefs_file_inode_operations;
extern const struct file_operations orangefs_file_operations;
extern const struct inode_operations orangefs_symlink_inode_operations;
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 4113eb0495bf..c1b5174cb5a9 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -80,11 +80,6 @@ static int __init orangefs_init(void)
int ret = -1;
__u32 i = 0;
- ret = bdi_init(&orangefs_backing_dev_info);
-
- if (ret)
- return ret;
-
if (op_timeout_secs < 0)
op_timeout_secs = 0;
@@ -94,7 +89,7 @@ static int __init orangefs_init(void)
/* initialize global book keeping data structures */
ret = op_cache_initialize();
if (ret < 0)
- goto err;
+ goto out;
ret = orangefs_inode_cache_initialize();
if (ret < 0)
@@ -181,9 +176,6 @@ static int __init orangefs_init(void)
cleanup_op:
op_cache_finalize();
-err:
- bdi_destroy(&orangefs_backing_dev_info);
-
out:
return ret;
}
@@ -207,8 +199,6 @@ static void __exit orangefs_exit(void)
kfree(orangefs_htable_ops_in_progress);
- bdi_destroy(&orangefs_backing_dev_info);
-
pr_info("orangefs: module version %s unloaded\n", ORANGEFS_VERSION);
}
--
2.10.2
^ permalink raw reply related
* [PATCH 23/24] fs: Remove SB_I_DYNBDI flag
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Now that all bdi structures filesystems use are properly refcounted, we
can remove the SB_I_DYNBDI flag.
Signed-off-by: Jan Kara <jack@suse.cz>
---
drivers/mtd/mtdsuper.c | 1 -
fs/gfs2/ops_fstype.c | 1 -
fs/nfs/super.c | 1 -
fs/nilfs2/super.c | 1 -
fs/super.c | 5 +----
include/linux/fs.h | 3 ---
6 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index e69e7855e31f..e43fea896d1e 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -53,7 +53,6 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
sb->s_mtd = mtd;
sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
sb->s_bdi = bdi_get(mtd_bdi);
- sb->s_iflags |= SB_I_DYNBDI;
return 0;
}
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index fe8248f8b54b..79716e24f923 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1223,7 +1223,6 @@ static int set_gfs2_super(struct super_block *s, void *data)
s->s_bdev = data;
s->s_dev = s->s_bdev->bd_dev;
s->s_bdi = bdi_get(s->s_bdev->bd_bdi);
- s->s_iflags |= SB_I_DYNBDI;
return 0;
}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 16f4d92a96ec..0eca0fcf635f 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2386,7 +2386,6 @@ int nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
nfs_initialise_sb(sb);
sb->s_bdi = bdi_get(old_sb->s_bdi);
- sb->s_iflags |= SB_I_DYNBDI;
return 0;
}
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index feb796a38b8d..926682981d61 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1069,7 +1069,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_max_links = NILFS_LINK_MAX;
sb->s_bdi = bdi_get(sb->s_bdev->bd_bdi);
- sb->s_iflags |= SB_I_DYNBDI;
err = load_nilfs(nilfs, sb);
if (err)
diff --git a/fs/super.c b/fs/super.c
index dfb95ccd4351..76c1daf611dc 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -446,10 +446,9 @@ void generic_shutdown_super(struct super_block *sb)
hlist_del_init(&sb->s_instances);
spin_unlock(&sb_lock);
up_write(&sb->s_umount);
- if (sb->s_iflags & SB_I_DYNBDI) {
+ if (sb->s_bdi != &noop_backing_dev_info) {
bdi_put(sb->s_bdi);
sb->s_bdi = &noop_backing_dev_info;
- sb->s_iflags &= ~SB_I_DYNBDI;
}
}
@@ -1048,7 +1047,6 @@ static int set_bdev_super(struct super_block *s, void *data)
s->s_bdev = data;
s->s_dev = s->s_bdev->bd_dev;
s->s_bdi = bdi_get(s->s_bdev->bd_bdi);
- s->s_iflags |= SB_I_DYNBDI;
return 0;
}
@@ -1275,7 +1273,6 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
}
WARN_ON(sb->s_bdi != &noop_backing_dev_info);
sb->s_bdi = bdi;
- sb->s_iflags |= SB_I_DYNBDI;
return 0;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8ed8b6d1bc54..409e2bba424f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1267,9 +1267,6 @@ struct mm_struct;
/* sb->s_iflags to limit user namespace mounts */
#define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
-/* Temporary flag until all filesystems are converted to dynamic bdis */
-#define SB_I_DYNBDI 0x00000100
-
/* Possible states of 'frozen' field */
enum {
SB_UNFROZEN = 0, /* FS is unfrozen */
--
2.10.2
^ permalink raw reply related
* [PATCH 02/24] bdi: Provide bdi_register_va()
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Add function that registers bdi and takes va_list instead of variable
number of arguments.
Signed-off-by: Jan Kara <jack@suse.cz>
---
include/linux/backing-dev.h | 2 ++
mm/backing-dev.c | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 81c07ade4305..6865b1c8b122 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -30,6 +30,8 @@ void bdi_put(struct backing_dev_info *bdi);
__printf(3, 4)
int bdi_register(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, ...);
+int bdi_register_va(struct backing_dev_info *bdi, struct device *parent,
+ const char *fmt, va_list args);
int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
void bdi_unregister(struct backing_dev_info *bdi);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 7a5ba4163656..d59571023df7 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -824,18 +824,15 @@ struct backing_dev_info *bdi_alloc(gfp_t gfp_mask)
}
EXPORT_SYMBOL(bdi_alloc);
-int bdi_register(struct backing_dev_info *bdi, struct device *parent,
- const char *fmt, ...)
+int bdi_register_va(struct backing_dev_info *bdi, struct device *parent,
+ const char *fmt, va_list args)
{
- va_list args;
struct device *dev;
if (bdi->dev) /* The driver needs to use separate queues per device */
return 0;
- va_start(args, fmt);
dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args);
- va_end(args);
if (IS_ERR(dev))
return PTR_ERR(dev);
@@ -851,6 +848,19 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
trace_writeback_bdi_register(bdi);
return 0;
}
+EXPORT_SYMBOL(bdi_register_va);
+
+int bdi_register(struct backing_dev_info *bdi, struct device *parent,
+ const char *fmt, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, fmt);
+ ret = bdi_register_va(bdi, parent, fmt, args);
+ va_end(args);
+ return ret;
+}
EXPORT_SYMBOL(bdi_register);
int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
--
2.10.2
^ permalink raw reply related
* [PATCH 24/24] block: Remove unused functions
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Now that all backing_dev_info structure are allocated separately, we can
drop some unused functions.
Signed-off-by: Jan Kara <jack@suse.cz>
---
include/linux/backing-dev.h | 5 -----
mm/backing-dev.c | 54 +++++----------------------------------------
2 files changed, 5 insertions(+), 54 deletions(-)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 6865b1c8b122..f39822a06305 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -17,8 +17,6 @@
#include <linux/backing-dev-defs.h>
#include <linux/slab.h>
-int __must_check bdi_init(struct backing_dev_info *bdi);
-
static inline struct backing_dev_info *bdi_get(struct backing_dev_info *bdi)
{
kref_get(&bdi->refcnt);
@@ -32,12 +30,9 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, ...);
int bdi_register_va(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, va_list args);
-int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
void bdi_unregister(struct backing_dev_info *bdi);
-int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
-void bdi_destroy(struct backing_dev_info *bdi);
struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id);
struct backing_dev_info *bdi_alloc(gfp_t gfp_mask);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 82fee0f52d06..38b1197f7479 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -12,8 +12,6 @@
#include <linux/device.h>
#include <trace/events/writeback.h>
-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
-
struct backing_dev_info noop_backing_dev_info = {
.name = "noop",
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
@@ -242,6 +240,8 @@ static __init int bdi_class_init(void)
}
postcore_initcall(bdi_class_init);
+static int bdi_init(struct backing_dev_info *bdi);
+
static int __init default_bdi_init(void)
{
int err;
@@ -771,7 +771,7 @@ static void cgwb_bdi_destroy(struct backing_dev_info *bdi) { }
#endif /* CONFIG_CGROUP_WRITEBACK */
-int bdi_init(struct backing_dev_info *bdi)
+static int bdi_init(struct backing_dev_info *bdi)
{
int ret;
@@ -791,7 +791,6 @@ int bdi_init(struct backing_dev_info *bdi)
return ret;
}
-EXPORT_SYMBOL(bdi_init);
struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id)
{
@@ -864,12 +863,6 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
}
EXPORT_SYMBOL(bdi_register);
-int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
-{
- return bdi_register(bdi, NULL, "%u:%u", MAJOR(dev), MINOR(dev));
-}
-EXPORT_SYMBOL(bdi_register_dev);
-
int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner)
{
int rc;
@@ -923,19 +916,14 @@ void bdi_unregister(struct backing_dev_info *bdi)
}
}
-static void bdi_exit(struct backing_dev_info *bdi)
-{
- WARN_ON_ONCE(bdi->dev);
- wb_exit(&bdi->wb);
-}
-
static void release_bdi(struct kref *ref)
{
struct backing_dev_info *bdi =
container_of(ref, struct backing_dev_info, refcnt);
bdi_unregister(bdi);
- bdi_exit(bdi);
+ WARN_ON_ONCE(bdi->dev);
+ wb_exit(&bdi->wb);
kfree(bdi);
}
@@ -944,38 +932,6 @@ void bdi_put(struct backing_dev_info *bdi)
kref_put(&bdi->refcnt, release_bdi);
}
-void bdi_destroy(struct backing_dev_info *bdi)
-{
- bdi_unregister(bdi);
- bdi_exit(bdi);
-}
-EXPORT_SYMBOL(bdi_destroy);
-
-/*
- * For use from filesystems to quickly init and register a bdi associated
- * with dirty writeback
- */
-int bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
-{
- int err;
-
- bdi->name = name;
- bdi->capabilities = 0;
- err = bdi_init(bdi);
- if (err)
- return err;
-
- err = bdi_register(bdi, NULL, "%.28s-%ld", name,
- atomic_long_inc_return(&bdi_seq));
- if (err) {
- bdi_destroy(bdi);
- return err;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(bdi_setup_and_register);
-
static wait_queue_head_t congestion_wqh[2] = {
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
--
2.10.2
^ permalink raw reply related
* [PATCH 22/24] ubifs: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, Richard Weinberger,
Artem Bityutskiy, Adrian Hunter, linux-mtd
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Richard Weinberger <richard@nod.at>
CC: Artem Bityutskiy <dedekind1@gmail.com>
CC: Adrian Hunter <adrian.hunter@intel.com>
CC: linux-mtd@lists.infradead.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ubifs/super.c | 23 +++++++----------------
fs/ubifs/ubifs.h | 3 ---
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index e08aa04fc835..34810eb52b22 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1827,7 +1827,6 @@ static void ubifs_put_super(struct super_block *sb)
}
ubifs_umount(c);
- bdi_destroy(&c->bdi);
ubi_close_volume(c->ubi);
mutex_unlock(&c->umount_mutex);
}
@@ -2019,29 +2018,23 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
goto out;
}
+ err = ubifs_parse_options(c, data, 0);
+ if (err)
+ goto out_close;
+
/*
* UBIFS provides 'backing_dev_info' in order to disable read-ahead. For
* UBIFS, I/O is not deferred, it is done immediately in readpage,
* which means the user would have to wait not just for their own I/O
* but the read-ahead I/O as well i.e. completely pointless.
*
- * Read-ahead will be disabled because @c->bdi.ra_pages is 0.
+ * Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0.
*/
- c->bdi.name = "ubifs",
- c->bdi.capabilities = 0;
- err = bdi_init(&c->bdi);
+ err = super_setup_bdi_name(sb, "ubifs_%d_%d", c->vi.ubi_num,
+ c->vi.vol_id);
if (err)
goto out_close;
- err = bdi_register(&c->bdi, NULL, "ubifs_%d_%d",
- c->vi.ubi_num, c->vi.vol_id);
- if (err)
- goto out_bdi;
-
- err = ubifs_parse_options(c, data, 0);
- if (err)
- goto out_bdi;
- sb->s_bdi = &c->bdi;
sb->s_fs_info = c;
sb->s_magic = UBIFS_SUPER_MAGIC;
sb->s_blocksize = UBIFS_BLOCK_SIZE;
@@ -2080,8 +2073,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
ubifs_umount(c);
out_unlock:
mutex_unlock(&c->umount_mutex);
-out_bdi:
- bdi_destroy(&c->bdi);
out_close:
ubi_close_volume(c->ubi);
out:
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index ca72382ce6cc..41b42a425b42 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -968,7 +968,6 @@ struct ubifs_debug_info;
* struct ubifs_info - UBIFS file-system description data structure
* (per-superblock).
* @vfs_sb: VFS @struct super_block object
- * @bdi: backing device info object to make VFS happy and disable read-ahead
*
* @highest_inum: highest used inode number
* @max_sqnum: current global sequence number
@@ -1216,7 +1215,6 @@ struct ubifs_debug_info;
*/
struct ubifs_info {
struct super_block *vfs_sb;
- struct backing_dev_info bdi;
ino_t highest_inum;
unsigned long long max_sqnum;
@@ -1457,7 +1455,6 @@ extern const struct inode_operations ubifs_file_inode_operations;
extern const struct file_operations ubifs_dir_operations;
extern const struct inode_operations ubifs_dir_inode_operations;
extern const struct inode_operations ubifs_symlink_inode_operations;
-extern struct backing_dev_info ubifs_backing_dev_info;
extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
/* io.c */
--
2.10.2
^ permalink raw reply related
* [PATCH 20/24] ncpfs: Convert to separately allocated bdi
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Christoph Hellwig, linux-block, Jan Kara, Petr Vandrovec
In-Reply-To: <20170202173422.3240-1-jack@suse.cz>
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Petr Vandrovec <petr@vandrovec.name>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ncpfs/inode.c | 8 ++------
fs/ncpfs/ncp_fs_sb.h | 1 -
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 7eb89c23c847..245c23d516a4 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -553,12 +553,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
sb->s_magic = NCP_SUPER_MAGIC;
sb->s_op = &ncp_sops;
sb->s_d_op = &ncp_dentry_operations;
- sb->s_bdi = &server->bdi;
server = NCP_SBP(sb);
memset(server, 0, sizeof(*server));
- error = bdi_setup_and_register(&server->bdi, "ncpfs");
+ error = super_setup_bdi(sb);
if (error)
goto out_fput;
@@ -567,7 +566,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
if (data.info_fd != -1) {
struct socket *info_sock = sockfd_lookup(data.info_fd, &error);
if (!info_sock)
- goto out_bdi;
+ goto out_fput;
server->info_sock = info_sock;
error = -EBADFD;
if (info_sock->type != SOCK_STREAM)
@@ -745,8 +744,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
out_fput2:
if (server->info_sock)
sockfd_put(server->info_sock);
-out_bdi:
- bdi_destroy(&server->bdi);
out_fput:
sockfd_put(sock);
out:
@@ -787,7 +784,6 @@ static void ncp_put_super(struct super_block *sb)
kill_pid(server->m.wdog_pid, SIGTERM, 1);
put_pid(server->m.wdog_pid);
- bdi_destroy(&server->bdi);
kfree(server->priv.data);
kfree(server->auth.object_name);
vfree(server->rxbuf);
diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
index 55e26fd80886..366fd63cc506 100644
--- a/fs/ncpfs/ncp_fs_sb.h
+++ b/fs/ncpfs/ncp_fs_sb.h
@@ -143,7 +143,6 @@ struct ncp_server {
size_t len;
__u8 data[128];
} unexpected_packet;
- struct backing_dev_info bdi;
};
extern void ncp_tcp_rcv_proc(struct work_struct *work);
--
2.10.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox