* __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 *
* 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;
}
* 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 */
* 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.
*/
#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 */
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);
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
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;
tp->t_blk_res = 0;
}
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+ memalloc_nofs_restore(tp->t_memalloc);
return error;
}
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);
/*
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);
}
/* 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);
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 */
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;
/*