Re: [PATCH v3] jbd2: preserve original nofs flag during journal restart
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> Reviewed-by: Jan Kara Thanks, applied. - Ted
Re: [PATCH v3] jbd2: preserve original nofs flag during journal restart
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 > Reviewed-by: Jan Kara Thanks, applied. - Ted
[PATCH v3] jbd2: preserve original nofs flag during journal restart
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 ErdoganReviewed-by: Jan Kara --- 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(>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
[PATCH v3] jbd2: preserve original nofs flag during journal restart
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 Reviewed-by: Jan Kara --- 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(>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