Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-09 Thread Omar Sandoval
On Wed, Nov 07, 2018 at 05:01:19PM +0100, David Sterba wrote: > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > From: Omar Sandoval > > > > There's a race between close_ctree() and cleaner_kthread(). > > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > >

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-07 Thread David Sterba
On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > There's a race between close_ctree() and cleaner_kthread(). > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > sees it set, but this is racy; the cleaner might have already checked >

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Chris Mason
On 1 Nov 2018, at 12:00, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:29:48PM +0100, David Sterba wrote: >>> >>> How is that? kthread_stop() frees the task struct, so >>> wake_up_process() >>> would be a use-after-free. >> >> That was an assumption for the demonstration purposes, the

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 06:50:03PM +0200, Nikolay Borisov wrote: > > > On 1.11.18 г. 18:44 ч., David Sterba wrote: > > On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: > >>> That was an assumption for the demonstration purposes, the wording was > >>> confusing sorry. > >> > >> Oh,

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 18:44 ч., David Sterba wrote: > On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: >>> That was an assumption for the demonstration purposes, the wording was >>> confusing sorry. >> >> Oh, well in that case, that's exactly what kthread_park() is ;) Stop the >> thread

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: > > That was an assumption for the demonstration purposes, the wording was > > confusing sorry. > > Oh, well in that case, that's exactly what kthread_park() is ;) Stop the > thread and make wake_up a noop, and then we don't need to

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:29:48PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > > On Thu, Nov 01, 2018 at

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > > On 1 Nov 2018, at 6:15, David

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 08:23:17AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700,

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > > On 1 Nov 2018, at 6:15, David

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700,

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > >> From: Omar Sandoval > > >> > > >> There's a

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > >> From: Omar Sandoval > > >> > > >> There's a

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 16:35 ч., Nikolay Borisov wrote: > > > On 31.10.18 г. 19:06 ч., Omar Sandoval wrote: >> From: Omar Sandoval >> >> There's a race between close_ctree() and cleaner_kthread(). >> close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it >> sees it set, but this is

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > >> From: Omar Sandoval > >> > >> There's a race between close_ctree() and cleaner_kthread(). > >> close_ctree() sets

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 31.10.18 г. 19:06 ч., Omar Sandoval wrote: > From: Omar Sandoval > > There's a race between close_ctree() and cleaner_kthread(). > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > sees it set, but this is racy; the cleaner might have already checked > the bit and

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Chris Mason
On 1 Nov 2018, at 6:15, David Sterba wrote: > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: >> From: Omar Sandoval >> >> There's a race between close_ctree() and cleaner_kthread(). >> close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it >> sees it set, but this

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > There's a race between close_ctree() and cleaner_kthread(). > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > sees it set, but this is racy; the cleaner might have already checked >

[PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-10-31 Thread Omar Sandoval
From: Omar Sandoval There's a race between close_ctree() and cleaner_kthread(). close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it sees it set, but this is racy; the cleaner might have already checked the bit and could be cleaning stuff. In particular, if it deletes unused