Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1643322 > unrolled thread
| Started by | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| First post | 2017-05-17 14:40 +0200 |
| Last post | 2017-05-20 06:20 +0200 |
| Articles | 10 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] jbd2: preserve original nofs flag during journal restart Tahsin Erdogan <tahsin@google.com> - 2017-05-17 14:40 +0200
Re: [PATCH] jbd2: preserve original nofs flag during journal restart Jan Kara <jack@suse.cz> - 2017-05-17 16:10 +0200
Re: [PATCH] jbd2: preserve original nofs flag during journal restart Michal Hocko <mhocko@kernel.org> - 2017-05-17 16:20 +0200
Re: [PATCH] jbd2: preserve original nofs flag during journal restart Jan Kara <jack@suse.cz> - 2017-05-17 17:00 +0200
Re: [PATCH] jbd2: preserve original nofs flag during journal restart Michal Hocko <mhocko@kernel.org> - 2017-05-17 17:30 +0200
[PATCH v2] jbd2: preserve original nofs flag during journal restart Tahsin Erdogan <tahsin@google.com> - 2017-05-17 18:20 +0200
Re: [PATCH v2] jbd2: preserve original nofs flag during journal restart Michal Hocko <mhocko@kernel.org> - 2017-05-18 11:20 +0200
Re: [PATCH v2] jbd2: preserve original nofs flag during journal restart Jan Kara <jack@suse.cz> - 2017-05-18 11:40 +0200
[PATCH v3] jbd2: preserve original nofs flag during journal restart Tahsin Erdogan <tahsin@google.com> - 2017-05-18 18:30 +0200
Re: [PATCH v3] jbd2: preserve original nofs flag during journal restart Theodore Ts'o <tytso@mit.edu> - 2017-05-20 06:20 +0200
| From | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| Date | 2017-05-17 14:40 +0200 |
| Subject | [PATCH] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tI6pc-35o-27@gated-at.bofh.it> |
When a transaction starts, start_this_handle() saves current
PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
Journal restart is a special case that calls start_this_handle() without
stopping the transaction. start_this_handle() isn't aware that the
original value is already stored so it overwrites it with current value.
For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
at the end:
jbd2_journal_start()
jbd2__journal_restart()
jbd2_journal_stop()
Make jbd2__journal_restart() restore the original value before calling
start_this_handle().
Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
fs/jbd2/transaction.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 9ee4832b6f8b..dfd6afebdfeb 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -680,6 +680,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
handle->h_buffer_credits = nblocks;
+ memalloc_nofs_restore(handle->saved_alloc_context);
ret = start_this_handle(journal, handle, gfp_mask);
return ret;
}
--
2.13.0.303.g4ebf302169-goog
[toc] | [next] | [standalone]
| From | Jan Kara <jack@suse.cz> |
|---|---|
| Date | 2017-05-17 16:10 +0200 |
| Message-ID | <tI7Oj-43z-55@gated-at.bofh.it> |
| In reply to | #1643322 |
On Wed 17-05-17 05:33:01, Tahsin Erdogan wrote:
> When a transaction starts, start_this_handle() saves current
> PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
> Journal restart is a special case that calls start_this_handle() without
> stopping the transaction. start_this_handle() isn't aware that the
> original value is already stored so it overwrites it with current value.
>
> For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
> at the end:
>
> jbd2_journal_start()
> jbd2__journal_restart()
> jbd2_journal_stop()
>
> Make jbd2__journal_restart() restore the original value before calling
> start_this_handle().
>
> Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
> Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Thanks for catching this! The patch looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/jbd2/transaction.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
> index 9ee4832b6f8b..dfd6afebdfeb 100644
> --- a/fs/jbd2/transaction.c
> +++ b/fs/jbd2/transaction.c
> @@ -680,6 +680,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
>
> rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
> handle->h_buffer_credits = nblocks;
> + memalloc_nofs_restore(handle->saved_alloc_context);
> ret = start_this_handle(journal, handle, gfp_mask);
> return ret;
> }
> --
> 2.13.0.303.g4ebf302169-goog
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-05-17 16:20 +0200 |
| Message-ID | <tI7XY-48K-25@gated-at.bofh.it> |
| In reply to | #1643322 |
On Wed 17-05-17 05:33:01, Tahsin Erdogan wrote:
> When a transaction starts, start_this_handle() saves current
> PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
> Journal restart is a special case that calls start_this_handle() without
> stopping the transaction. start_this_handle() isn't aware that the
> original value is already stored so it overwrites it with current value.
>
> For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
> at the end:
>
> jbd2_journal_start()
> jbd2__journal_restart()
> jbd2_journal_stop()
>
> Make jbd2__journal_restart() restore the original value before calling
> start_this_handle().
>
> Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
> Signed-off-by: Tahsin Erdogan <tahsin@google.com>
> ---
> fs/jbd2/transaction.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
> index 9ee4832b6f8b..dfd6afebdfeb 100644
> --- a/fs/jbd2/transaction.c
> +++ b/fs/jbd2/transaction.c
> @@ -680,6 +680,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
>
> rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
> handle->h_buffer_credits = nblocks;
> + memalloc_nofs_restore(handle->saved_alloc_context);
> ret = start_this_handle(journal, handle, gfp_mask);
> return ret;
> }
I remember Jack has mentioned something about nested transaction back
then when reviewing the patch. But I cannot remember or find a pointer
to that email. I have a vague recollection that there is a reference
counting for those transactions.
Anyway, Is this patch really correct? So let's say we are in
the transaction context already and then you disable the scope
NOFS protection, start_this_handle will allocate before it calls
memalloc_nofs_save and that would recurse to the filesystem. If
anything wouldn't it be better to simply call memalloc_nofs_save only if
we start a new transaction? I thought we were doing that already but the
code is so convoluted I have hard time to wrap my head around it.
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Jan Kara <jack@suse.cz> |
|---|---|
| Date | 2017-05-17 17:00 +0200 |
| Message-ID | <tI8AG-4o1-41@gated-at.bofh.it> |
| In reply to | #1643401 |
On Wed 17-05-17 16:13:57, Michal Hocko wrote:
> On Wed 17-05-17 05:33:01, Tahsin Erdogan wrote:
> > When a transaction starts, start_this_handle() saves current
> > PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
> > Journal restart is a special case that calls start_this_handle() without
> > stopping the transaction. start_this_handle() isn't aware that the
> > original value is already stored so it overwrites it with current value.
> >
> > For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
> > at the end:
> >
> > jbd2_journal_start()
> > jbd2__journal_restart()
> > jbd2_journal_stop()
> >
> > Make jbd2__journal_restart() restore the original value before calling
> > start_this_handle().
> >
> > Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
> > Signed-off-by: Tahsin Erdogan <tahsin@google.com>
> > ---
> > fs/jbd2/transaction.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
> > index 9ee4832b6f8b..dfd6afebdfeb 100644
> > --- a/fs/jbd2/transaction.c
> > +++ b/fs/jbd2/transaction.c
> > @@ -680,6 +680,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
> >
> > rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
> > handle->h_buffer_credits = nblocks;
> > + memalloc_nofs_restore(handle->saved_alloc_context);
> > ret = start_this_handle(journal, handle, gfp_mask);
> > return ret;
> > }
>
> I remember Jack has mentioned something about nested transaction back
> then when reviewing the patch. But I cannot remember or find a pointer
> to that email. I have a vague recollection that there is a reference
> counting for those transactions.
>
> Anyway, Is this patch really correct? So let's say we are in
> the transaction context already and then you disable the scope
> NOFS protection, start_this_handle will allocate before it calls
> memalloc_nofs_save and that would recurse to the filesystem. If
> anything wouldn't it be better to simply call memalloc_nofs_save only if
> we start a new transaction? I thought we were doing that already but the
> code is so convoluted I have hard time to wrap my head around it.
I was thinking about his as well but the fact is jbd2__journal_restart()
actually does equivalent of jbd2_journal_stop() for the handle above the
place where memalloc_nofs_restore() was added so in this sense we really
miss memalloc_nofs_restore() there... So what Tahsin did makes sense.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-05-17 17:30 +0200 |
| Message-ID | <tI93I-4Nh-19@gated-at.bofh.it> |
| In reply to | #1643437 |
On Wed 17-05-17 16:56:27, Jan Kara wrote:
> On Wed 17-05-17 16:13:57, Michal Hocko wrote:
> > On Wed 17-05-17 05:33:01, Tahsin Erdogan wrote:
> > > When a transaction starts, start_this_handle() saves current
> > > PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
> > > Journal restart is a special case that calls start_this_handle() without
> > > stopping the transaction. start_this_handle() isn't aware that the
> > > original value is already stored so it overwrites it with current value.
> > >
> > > For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
> > > at the end:
> > >
> > > jbd2_journal_start()
> > > jbd2__journal_restart()
> > > jbd2_journal_stop()
> > >
> > > Make jbd2__journal_restart() restore the original value before calling
> > > start_this_handle().
> > >
> > > Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
> > > Signed-off-by: Tahsin Erdogan <tahsin@google.com>
> > > ---
> > > fs/jbd2/transaction.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
> > > index 9ee4832b6f8b..dfd6afebdfeb 100644
> > > --- a/fs/jbd2/transaction.c
> > > +++ b/fs/jbd2/transaction.c
> > > @@ -680,6 +680,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
> > >
> > > rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
> > > handle->h_buffer_credits = nblocks;
> > > + memalloc_nofs_restore(handle->saved_alloc_context);
> > > ret = start_this_handle(journal, handle, gfp_mask);
> > > return ret;
> > > }
> >
> > I remember Jack has mentioned something about nested transaction back
> > then when reviewing the patch. But I cannot remember or find a pointer
> > to that email. I have a vague recollection that there is a reference
> > counting for those transactions.
> >
> > Anyway, Is this patch really correct? So let's say we are in
> > the transaction context already and then you disable the scope
> > NOFS protection, start_this_handle will allocate before it calls
> > memalloc_nofs_save and that would recurse to the filesystem. If
> > anything wouldn't it be better to simply call memalloc_nofs_save only if
> > we start a new transaction? I thought we were doing that already but the
> > code is so convoluted I have hard time to wrap my head around it.
>
> I was thinking about his as well but the fact is jbd2__journal_restart()
> actually does equivalent of jbd2_journal_stop() for the handle above the
> place where memalloc_nofs_restore() was added so in this sense we really
> miss memalloc_nofs_restore() there... So what Tahsin did makes sense.
OK, I will trust you ;). This deserves a comment then, I believe.
Thanks!
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| Date | 2017-05-17 18:20 +0200 |
| Subject | [PATCH v2] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tI9Q6-5lu-23@gated-at.bofh.it> |
| In reply to | #1643463 |
When a transaction starts, start_this_handle() saves current
PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
Journal restart is a special case that calls start_this_handle() without
stopping the transaction. start_this_handle() isn't aware that the
original value is already stored so it overwrites it with current value.
For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
at the end:
jbd2_journal_start()
jbd2__journal_restart()
jbd2_journal_stop()
Make jbd2__journal_restart() restore the original value before calling
start_this_handle().
Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
v2: added comment to jbd2__journal_restart()
fs/jbd2/transaction.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 9ee4832b6f8b..05c0323493fb 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -680,6 +680,8 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
handle->h_buffer_credits = nblocks;
+ /* Restore original nofs flag as jbd2_journal_stop() would do. */
+ memalloc_nofs_restore(handle->saved_alloc_context);
ret = start_this_handle(journal, handle, gfp_mask);
return ret;
}
--
2.13.0.303.g4ebf302169-goog
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-05-18 11:20 +0200 |
| Subject | Re: [PATCH v2] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tIpLb-8ip-3@gated-at.bofh.it> |
| In reply to | #1643495 |
On Wed 17-05-17 09:16:29, Tahsin Erdogan wrote: [...] > diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c > index 9ee4832b6f8b..05c0323493fb 100644 > --- a/fs/jbd2/transaction.c > +++ b/fs/jbd2/transaction.c > @@ -680,6 +680,8 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask) > > rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_); > handle->h_buffer_credits = nblocks; > + /* Restore original nofs flag as jbd2_journal_stop() would do. */ I was thinking something more specific like /* * Restore the original nofs context because the journal restart * is basically the same thing as journal stop and start. * start_this_handle will start a new nofs context. */ > + memalloc_nofs_restore(handle->saved_alloc_context); > ret = start_this_handle(journal, handle, gfp_mask); > return ret; > } > -- > 2.13.0.303.g4ebf302169-goog > -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Jan Kara <jack@suse.cz> |
|---|---|
| Date | 2017-05-18 11:40 +0200 |
| Subject | Re: [PATCH v2] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tIq4y-8sq-11@gated-at.bofh.it> |
| In reply to | #1644001 |
On Thu 18-05-17 11:12:53, Michal Hocko wrote: > On Wed 17-05-17 09:16:29, Tahsin Erdogan wrote: > [...] > > diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c > > index 9ee4832b6f8b..05c0323493fb 100644 > > --- a/fs/jbd2/transaction.c > > +++ b/fs/jbd2/transaction.c > > @@ -680,6 +680,8 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask) > > > > rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_); > > handle->h_buffer_credits = nblocks; > > + /* Restore original nofs flag as jbd2_journal_stop() would do. */ > > I was thinking something more specific like > /* > * Restore the original nofs context because the journal restart > * is basically the same thing as journal stop and start. > * start_this_handle will start a new nofs context. > */ Yeah, this is much better. Tahsin, please use Michal's version. Thanks! Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR
[toc] | [prev] | [next] | [standalone]
| From | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| Date | 2017-05-18 18:30 +0200 |
| Subject | [PATCH v3] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tIwtj-5bz-9@gated-at.bofh.it> |
| In reply to | #1644017 |
When a transaction starts, start_this_handle() saves current
PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
Journal restart is a special case that calls start_this_handle() without
stopping the transaction. start_this_handle() isn't aware that the
original value is already stored so it overwrites it with current value.
For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
at the end:
jbd2_journal_start()
jbd2__journal_restart()
jbd2_journal_stop()
Make jbd2__journal_restart() restore the original value before calling
start_this_handle().
Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
v3: Use Michal's suggested comment in jbd2__journal_restart()
v2: added comment to jbd2__journal_restart()
fs/jbd2/transaction.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 9ee4832b6f8b..2d30a6da7013 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -680,6 +680,12 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
handle->h_buffer_credits = nblocks;
+ /*
+ * Restore the original nofs context because the journal restart
+ * is basically the same thing as journal stop and start.
+ * start_this_handle will start a new nofs context.
+ */
+ memalloc_nofs_restore(handle->saved_alloc_context);
ret = start_this_handle(journal, handle, gfp_mask);
return ret;
}
--
2.13.0.303.g4ebf302169-goog
[toc] | [prev] | [next] | [standalone]
| From | Theodore Ts'o <tytso@mit.edu> |
|---|---|
| Date | 2017-05-20 06:20 +0200 |
| Subject | Re: [PATCH v3] jbd2: preserve original nofs flag during journal restart |
| Message-ID | <tJ41X-4n6-1@gated-at.bofh.it> |
| In reply to | #1644731 |
On Thu, May 18, 2017 at 09:28:50AM -0700, Tahsin Erdogan wrote:
> When a transaction starts, start_this_handle() saves current
> PF_MEMALLOC_NOFS value so that it can be restored at journal stop time.
> Journal restart is a special case that calls start_this_handle() without
> stopping the transaction. start_this_handle() isn't aware that the
> original value is already stored so it overwrites it with current value.
>
> For instance, a call sequence like below leaves PF_MEMALLOC_NOFS flag set
> at the end:
>
> jbd2_journal_start()
> jbd2__journal_restart()
> jbd2_journal_stop()
>
> Make jbd2__journal_restart() restore the original value before calling
> start_this_handle().
>
> Fixes: 81378da64de6 ("jbd2: mark the transaction context with the scope GFP_NOFS context")
> Signed-off-by: Tahsin Erdogan <tahsin@google.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web