]> www.infradead.org Git - users/willy/linux.git/commitdiff
xfs: Convert to memalloc_nofs_save
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 27 Mar 2020 17:01:57 +0000 (13:01 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 24 Jun 2020 16:57:31 +0000 (12:57 -0400)
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) <willy@infradead.org>
fs/xfs/kmem.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_buf.c
fs/xfs/xfs_linux.h
fs/xfs/xfs_trans.c
fs/xfs/xfs_trans.h

index f1366475c389c0a7de3a1f4c9288cc4ae6abb919..c2d237159bfca59125f8f39cfb50b17d5e9ada38 100644 (file)
@@ -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 here. 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 here
  * and potentially deadlocking.
  */
 static void *
index b35611882ff9c565d740c8b80e17633a0096a41e..e3a4806e519d7e89f5854c360f4e6828c8e780c5 100644 (file)
@@ -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;
 }
 
@@ -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 = memalloc_nofs_save();
        __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS);
 
        /* we abort the update if there was an IO error */
index 20b748f7e1862fd9259c9d3f0ba8f672bb8305d6..b2c3d01c690b0361cfe080a8c45a00d6def61d39 100644 (file)
@@ -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.
                 */
index 9f70d2f68e059b019ad1f8a019f5df3c49411e12..e1daf242a53bc5346aeb49d5564fd5ad02c15a6a 100644 (file)
@@ -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) = current->flags, current->flags |= (f))
-#define current_clear_flags_nested(sp, f)      \
-               (*(sp) = current->flags, current->flags &= ~(f))
-#define current_restore_flags_nested(sp, f)    \
-               (current->flags = ((current->flags & ~(f)) | (*(sp) & (f))))
 
 #define NBBY           8               /* number of bits per byte */
 
index 3c94e5ff43160f4133db7186d63278ea5f0938f2..4ef1a0ff0a11313829cef70d74a21e93fdb2fd0a 100644 (file)
@@ -118,7 +118,7 @@ xfs_trans_dup(
 
        ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used;
        tp->t_rtx_res = tp->t_rtx_res_used;
-       ntp->t_pflags = tp->t_pflags;
+       ntp->t_memalloc = tp->t_memalloc;
 
        /* move deferred ops over to the new tp */
        xfs_defer_move(ntp, tp);
@@ -153,7 +153,7 @@ xfs_trans_reserve(
        bool                    rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
 
        /* Mark this thread as being in a transaction */
-       current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+       tp->t_memalloc = memalloc_nofs_save();
 
        /*
         * Attempt to reserve the needed disk blocks by decrementing
@@ -163,7 +163,7 @@ xfs_trans_reserve(
        if (blocks > 0) {
                error = xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd);
                if (error != 0) {
-                       current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+                       memalloc_nofs_restore(tp->t_memalloc);
                        return -ENOSPC;
                }
                tp->t_blk_res += blocks;
@@ -240,7 +240,7 @@ undo_blocks:
                tp->t_blk_res = 0;
        }
 
-       current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+       memalloc_nofs_restore(tp->t_memalloc);
 
        return error;
 }
@@ -861,7 +861,7 @@ __xfs_trans_commit(
 
        xfs_log_commit_cil(mp, tp, &commit_lsn, regrant);
 
-       current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+       memalloc_nofs_restore(tp->t_memalloc);
        xfs_trans_free(tp);
 
        /*
@@ -893,7 +893,7 @@ out_unreserve:
                        xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
                tp->t_ticket = 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);
 
@@ -954,7 +954,7 @@ xfs_trans_cancel(
        }
 
        /* 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);
 
        xfs_trans_free_items(tp, dirty);
        xfs_trans_free(tp);
index 8308bf6d7e4041662a9964873139f2c6e804e966..7aa2d5ff92459057c5aebf18a0643ba86b299f7b 100644 (file)
@@ -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;
 
 /*