From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EFEFC433E1 for ; Thu, 25 Jun 2020 11:31:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 195C820781 for ; Thu, 25 Jun 2020 11:31:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jgsOxsIb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 195C820781 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 70E5A6B0024; Thu, 25 Jun 2020 07:31:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F4126B0026; Thu, 25 Jun 2020 07:31:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51C646B0025; Thu, 25 Jun 2020 07:31:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 35C826B0023 for ; Thu, 25 Jun 2020 07:31:54 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F2BF02DFC for ; Thu, 25 Jun 2020 11:31:53 +0000 (UTC) X-FDA: 76967519706.29.order18_011219726e4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id D6DC118086CCA for ; Thu, 25 Jun 2020 11:31:53 +0000 (UTC) X-HE-Tag: order18_011219726e4c X-Filterd-Recvd-Size: 7865 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 25 Jun 2020 11:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=aZ5/VvBRxy1EdrAiC3gC+vdjhy3hMAejv9F0LfGr9Sg=; b=jgsOxsIbKipWm0r7hIyr6z1gah 3PZ4Dz0R6SiF6+L0i4am4QAUWUwqLCTfWyluQSd8AqBXZp0r2uOE5jJnhwVc9HhJAqlr/Mfmn5042 u40YVIeATMF7r2TplEtPv5uKrmht71dV/BnhWIvWOCJp9yoP6yzVxeif1wXToT2wnMu//AJSkJs37 T3IMv13ZdFqwHDZkTTzMWFJD8WUxuQOQ+2GaB7lGNY2UwnkGYcDIIHu8vi8+fxeoRYizOPWG/veYs +xbGefGDeWYCpmVs7jz9IvHsisfZbfZiBc4iPPH2ymHAPJi7d+hKLvQpcEKTcn2UXSTVu/9x2CNVk r16LcG/g==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1joQ6X-0001zW-0b; Thu, 25 Jun 2020 11:31:41 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-xfs@vger.kernel.org, dm-devel@redhat.com, Mikulas Patocka , Jens Axboe , NeilBrown Subject: [PATCH 3/6] xfs: Convert to memalloc_nofs_save Date: Thu, 25 Jun 2020 12:31:19 +0100 Message-Id: <20200625113122.7540-4-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625113122.7540-1-willy@infradead.org> References: <20200625113122.7540-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D6DC118086CCA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of using custom macros to set/restore PF_MEMALLOC_NOFS, use memalloc_nofs_save() like the rest of the kernel. Signed-off-by: Matthew Wilcox (Oracle) --- fs/xfs/kmem.c | 2 +- fs/xfs/xfs_aops.c | 4 ++-- fs/xfs/xfs_buf.c | 2 +- fs/xfs/xfs_linux.h | 6 ------ fs/xfs/xfs_trans.c | 14 +++++++------- fs/xfs/xfs_trans.h | 2 +- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c index f1366475c389..c2d237159bfc 100644 --- a/fs/xfs/kmem.c +++ b/fs/xfs/kmem.c @@ -35,7 +35,7 @@ kmem_alloc(size_t size, xfs_km_flags_t flags) * __vmalloc() will allocate data pages and auxiliary structures (e.g. * pagetables) with GFP_KERNEL, yet we may be under GFP_NOFS context her= e. Hence * we need to tell memory reclaim that we are in such a context via - * PF_MEMALLOC_NOFS to prevent memory reclaim re-entering the filesystem= here + * memalloc_nofs to prevent memory reclaim re-entering the filesystem he= re * and potentially deadlocking. */ static void * diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index b35611882ff9..e3a4806e519d 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -62,7 +62,7 @@ xfs_setfilesize_trans_alloc( * We hand off the transaction to the completion thread now, so * clear the flag here. */ - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); return 0; } =20 @@ -125,7 +125,7 @@ xfs_setfilesize_ioend( * thus we need to mark ourselves as being in a transaction manually. * Similarly for freeze protection. */ - current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + tp->t_memalloc =3D memalloc_nofs_save(); __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS); =20 /* we abort the update if there was an IO error */ diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 20b748f7e186..b2c3d01c690b 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -470,7 +470,7 @@ _xfs_buf_map_pages( * vm_map_ram() will allocate auxiliary structures (e.g. * pagetables) with GFP_KERNEL, yet we are likely to be under * GFP_NOFS context here. Hence we need to tell memory reclaim - * that we are in such a context via PF_MEMALLOC_NOFS to prevent + * that we are in such a context via memalloc_nofs to prevent * memory reclaim re-entering the filesystem here and * potentially deadlocking. */ diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 9f70d2f68e05..e1daf242a53b 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -104,12 +104,6 @@ typedef __u32 xfs_nlink_t; #define current_cpu() (raw_smp_processor_id()) #define current_pid() (current->pid) #define current_test_flags(f) (current->flags & (f)) -#define current_set_flags_nested(sp, f) \ - (*(sp) =3D current->flags, current->flags |=3D (f)) -#define current_clear_flags_nested(sp, f) \ - (*(sp) =3D current->flags, current->flags &=3D ~(f)) -#define current_restore_flags_nested(sp, f) \ - (current->flags =3D ((current->flags & ~(f)) | (*(sp) & (f)))) =20 #define NBBY 8 /* number of bits per byte */ =20 diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 3c94e5ff4316..4ef1a0ff0a11 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -118,7 +118,7 @@ xfs_trans_dup( =20 ntp->t_rtx_res =3D tp->t_rtx_res - tp->t_rtx_res_used; tp->t_rtx_res =3D tp->t_rtx_res_used; - ntp->t_pflags =3D tp->t_pflags; + ntp->t_memalloc =3D tp->t_memalloc; =20 /* move deferred ops over to the new tp */ xfs_defer_move(ntp, tp); @@ -153,7 +153,7 @@ xfs_trans_reserve( bool rsvd =3D (tp->t_flags & XFS_TRANS_RESERVE) !=3D 0; =20 /* Mark this thread as being in a transaction */ - current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + tp->t_memalloc =3D memalloc_nofs_save(); =20 /* * Attempt to reserve the needed disk blocks by decrementing @@ -163,7 +163,7 @@ xfs_trans_reserve( if (blocks > 0) { error =3D xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd); if (error !=3D 0) { - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); return -ENOSPC; } tp->t_blk_res +=3D blocks; @@ -240,7 +240,7 @@ xfs_trans_reserve( tp->t_blk_res =3D 0; } =20 - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); =20 return error; } @@ -861,7 +861,7 @@ __xfs_trans_commit( =20 xfs_log_commit_cil(mp, tp, &commit_lsn, regrant); =20 - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); xfs_trans_free(tp); =20 /* @@ -893,7 +893,7 @@ __xfs_trans_commit( xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); tp->t_ticket =3D NULL; } - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); xfs_trans_free_items(tp, !!error); xfs_trans_free(tp); =20 @@ -954,7 +954,7 @@ xfs_trans_cancel( } =20 /* mark this thread as no longer being in a transaction */ - current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + memalloc_nofs_restore(tp->t_memalloc); =20 xfs_trans_free_items(tp, dirty); xfs_trans_free(tp); diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 8308bf6d7e40..7aa2d5ff9245 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -118,6 +118,7 @@ typedef struct xfs_trans { unsigned int t_rtx_res; /* # of rt extents resvd */ unsigned int t_rtx_res_used; /* # of resvd rt extents used */ unsigned int t_flags; /* misc flags */ + unsigned int t_memalloc; /* saved memalloc state */ xfs_fsblock_t t_firstblock; /* first block allocated */ struct xlog_ticket *t_ticket; /* log mgr ticket */ struct xfs_mount *t_mountp; /* ptr to fs mount struct */ @@ -144,7 +145,6 @@ typedef struct xfs_trans { struct list_head t_items; /* log item descriptors */ struct list_head t_busy; /* list of busy extents */ struct list_head t_dfops; /* deferred operations */ - unsigned long t_pflags; /* saved process flags state */ } xfs_trans_t; =20 /* --=20 2.27.0