|
@@ -170,6 +170,17 @@ static inline void fs_reclaim_acquire(gfp_t gfp_mask) { }
|
|
|
static inline void fs_reclaim_release(gfp_t gfp_mask) { }
|
|
static inline void fs_reclaim_release(gfp_t gfp_mask) { }
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * memalloc_noio_save - Marks implicit GFP_NOIO allocation scope.
|
|
|
|
|
+ *
|
|
|
|
|
+ * This functions marks the beginning of the GFP_NOIO allocation scope.
|
|
|
|
|
+ * All further allocations will implicitly drop __GFP_IO flag and so
|
|
|
|
|
+ * they are safe for the IO critical section from the allocation recursion
|
|
|
|
|
+ * point of view. Use memalloc_noio_restore to end the scope with flags
|
|
|
|
|
+ * returned by this function.
|
|
|
|
|
+ *
|
|
|
|
|
+ * This function is safe to be used from any context.
|
|
|
|
|
+ */
|
|
|
static inline unsigned int memalloc_noio_save(void)
|
|
static inline unsigned int memalloc_noio_save(void)
|
|
|
{
|
|
{
|
|
|
unsigned int flags = current->flags & PF_MEMALLOC_NOIO;
|
|
unsigned int flags = current->flags & PF_MEMALLOC_NOIO;
|
|
@@ -177,11 +188,30 @@ static inline unsigned int memalloc_noio_save(void)
|
|
|
return flags;
|
|
return flags;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * memalloc_noio_restore - Ends the implicit GFP_NOIO scope.
|
|
|
|
|
+ * @flags: Flags to restore.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Ends the implicit GFP_NOIO scope started by memalloc_noio_save function.
|
|
|
|
|
+ * Always make sure that that the given flags is the return value from the
|
|
|
|
|
+ * pairing memalloc_noio_save call.
|
|
|
|
|
+ */
|
|
|
static inline void memalloc_noio_restore(unsigned int flags)
|
|
static inline void memalloc_noio_restore(unsigned int flags)
|
|
|
{
|
|
{
|
|
|
current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags;
|
|
current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * memalloc_nofs_save - Marks implicit GFP_NOFS allocation scope.
|
|
|
|
|
+ *
|
|
|
|
|
+ * This functions marks the beginning of the GFP_NOFS allocation scope.
|
|
|
|
|
+ * All further allocations will implicitly drop __GFP_FS flag and so
|
|
|
|
|
+ * they are safe for the FS critical section from the allocation recursion
|
|
|
|
|
+ * point of view. Use memalloc_nofs_restore to end the scope with flags
|
|
|
|
|
+ * returned by this function.
|
|
|
|
|
+ *
|
|
|
|
|
+ * This function is safe to be used from any context.
|
|
|
|
|
+ */
|
|
|
static inline unsigned int memalloc_nofs_save(void)
|
|
static inline unsigned int memalloc_nofs_save(void)
|
|
|
{
|
|
{
|
|
|
unsigned int flags = current->flags & PF_MEMALLOC_NOFS;
|
|
unsigned int flags = current->flags & PF_MEMALLOC_NOFS;
|
|
@@ -189,6 +219,14 @@ static inline unsigned int memalloc_nofs_save(void)
|
|
|
return flags;
|
|
return flags;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * memalloc_nofs_restore - Ends the implicit GFP_NOFS scope.
|
|
|
|
|
+ * @flags: Flags to restore.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Ends the implicit GFP_NOFS scope started by memalloc_nofs_save function.
|
|
|
|
|
+ * Always make sure that that the given flags is the return value from the
|
|
|
|
|
+ * pairing memalloc_nofs_save call.
|
|
|
|
|
+ */
|
|
|
static inline void memalloc_nofs_restore(unsigned int flags)
|
|
static inline void memalloc_nofs_restore(unsigned int flags)
|
|
|
{
|
|
{
|
|
|
current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags;
|
|
current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags;
|