On Fri, Aug 25, 2023 at 09:54:28PM +0800, Hao Xu wrote: > From: Hao Xu <howeyxu@xxxxxxxxxxx> > > if the log transaction is a sync one, let's fail the nowait try and > return -EAGAIN directly since sync transaction means blocked by IO. > > Signed-off-by: Hao Xu <howeyxu@xxxxxxxxxxx> > --- > fs/xfs/xfs_trans.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c > index 7988b4c7f36e..f1f84a3dd456 100644 > --- a/fs/xfs/xfs_trans.c > +++ b/fs/xfs/xfs_trans.c > @@ -968,12 +968,24 @@ __xfs_trans_commit( > xfs_csn_t commit_seq = 0; > int error = 0; > int sync = tp->t_flags & XFS_TRANS_SYNC; > + bool nowait = tp->t_flags & XFS_TRANS_NOWAIT; > + bool perm_log = tp->t_flags & XFS_TRANS_PERM_LOG_RES; > > trace_xfs_trans_commit(tp, _RET_IP_); > > + if (nowait && sync) { > + /* > + * Currently nowait is only from xfs_vn_update_time() > + * so perm_log is always false here, but let's make > + * code general. > + */ > + if (perm_log) > + xfs_defer_cancel(tp); > + goto out_unreserve; > + } This is fundamentally broken. We cannot about a transaction commit with dirty items at this point with shutting down the filesystem. This points to XFS_TRANS_NOWAIT being completely broken, too, because we don't call xfs_trans_set_sync() until just before we commit the transaction. At this point, it is -too late- for nowait+sync to be handled gracefully, and it will *always* go bad. IOWs, the whole transaction "nowait" semantics as designed and implemented is not a workable solution.... -Dave. -- Dave Chinner david@xxxxxxxxxxxxx