Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0be19afa authored by Ann Koehler's avatar Ann Koehler Committed by Greg Kroah-Hartman
Browse files

staging/lustre: restore __GFP_WAIT flag to memalloc calls



In Lustre 2.4, the flags passed to the memory allocation functions are
translated from CFS enumeration values types to the kernel GFP
values by calling cfs_alloc_flags_to_gfp(). This function adds
__GFP_WAIT to all flags except CFS_ALLOC_ATOMIC. In 2.5, when
the cfs wrappers were dropped, cfs_alloc_flags_to_gfp() was
removed and the CFS_ALLOC_xxxx was simply replaced with __GFP_xxxx.
This means that most memory allocation calls are missing the
__GFP_WAIT flag. The result is that Lustre experiences more ENOMEM
errors, many of which the higher levels of Lustre do not handle
robustly.
Notes GFP_NOFS = __GFP_WAIT | __GFP_IO. So the patch replaces
__GFP_IO with GFP_NOFS.
Patch does not add __GFP_WAIT to GFP_IOFS. GFP_IOFS was not used in
Lustre 2.4 so it has never been used with __GFP_WAIT.

Signed-off-by: default avatarAnn Koehler <amk@cray.com>
Signed-off-by: default avatarEmoly Liu <emoly.liu@intel.com>
Reviewed-on: http://review.whamcloud.com/9223
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4357


Reviewed-by: default avatarLiang Zhen <liang.zhen@intel.com>
Reviewed-by: default avatarJames Simmons <uja.ornl@gmail.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 35b2e1b7
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -153,7 +153,7 @@ do { \
 * default allocator
 * default allocator
 */
 */
#define LIBCFS_ALLOC(ptr, size) \
#define LIBCFS_ALLOC(ptr, size) \
	LIBCFS_ALLOC_GFP(ptr, size, __GFP_IO)
	LIBCFS_ALLOC_GFP(ptr, size, GFP_NOFS)


/**
/**
 * non-sleeping allocator
 * non-sleeping allocator
@@ -177,7 +177,7 @@ do { \


/** default numa allocator */
/** default numa allocator */
#define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size)				    \
#define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size)				    \
	LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO)
	LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)


#define LIBCFS_FREE(ptr, size)					  \
#define LIBCFS_FREE(ptr, size)					  \
do {								    \
do {								    \
+1 −1
Original line number Original line Diff line number Diff line
@@ -1141,7 +1141,7 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
	for (i = 0; i < npages; i++) {
	for (i = 0; i < npages; i++) {
		p->ibp_pages[i] = alloc_pages_node(
		p->ibp_pages[i] = alloc_pages_node(
				    cfs_cpt_spread_node(lnet_cpt_table(), cpt),
				    cfs_cpt_spread_node(lnet_cpt_table(), cpt),
				    __GFP_IO, 0);
				    GFP_NOFS, 0);
		if (p->ibp_pages[i] == NULL) {
		if (p->ibp_pages[i] == NULL) {
			CERROR("Can't allocate page %d of %d\n", i, npages);
			CERROR("Can't allocate page %d of %d\n", i, npages);
			kiblnd_free_pages(p);
			kiblnd_free_pages(p);
+1 −1
Original line number Original line Diff line number Diff line
@@ -2133,7 +2133,7 @@ extern struct kmem_cache *obdo_cachep;


#define OBDO_ALLOC(ptr)						       \
#define OBDO_ALLOC(ptr)						       \
do {									  \
do {									  \
	OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, __GFP_IO);	     \
	OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS);             \
} while(0)
} while(0)


#define OBDO_FREE(ptr)							\
#define OBDO_FREE(ptr)							\
+5 −5
Original line number Original line Diff line number Diff line
@@ -641,8 +641,8 @@ do { \
#define OBD_ALLOC_GFP(ptr, size, gfp_mask)				      \
#define OBD_ALLOC_GFP(ptr, size, gfp_mask)				      \
	__OBD_MALLOC_VERBOSE(ptr, NULL, 0, size, gfp_mask)
	__OBD_MALLOC_VERBOSE(ptr, NULL, 0, size, gfp_mask)


#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, __GFP_IO)
#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_NOFS)
#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_IOFS)
#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_KERNEL)
#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr)))
#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr)))
#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr)))
#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr)))


@@ -650,7 +650,7 @@ do { \
	__OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask)
	__OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask)


#define OBD_CPT_ALLOC(ptr, cptab, cpt, size)				      \
#define OBD_CPT_ALLOC(ptr, cptab, cpt, size)				      \
	OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO)
	OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)


#define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)				      \
#define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)				      \
	OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
	OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
@@ -793,10 +793,10 @@ do { \
} while(0)
} while(0)


#define OBD_SLAB_ALLOC(ptr, slab, size)					      \
#define OBD_SLAB_ALLOC(ptr, slab, size)					      \
	OBD_SLAB_ALLOC_GFP(ptr, slab, size, __GFP_IO)
	OBD_SLAB_ALLOC_GFP(ptr, slab, size, GFP_NOFS)


#define OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, size)			      \
#define OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, size)			      \
	OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, __GFP_IO)
	OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, GFP_NOFS)


#define OBD_SLAB_ALLOC_PTR(ptr, slab)					      \
#define OBD_SLAB_ALLOC_PTR(ptr, slab)					      \
	OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr)))
	OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr)))
+6 −7
Original line number Original line Diff line number Diff line
@@ -112,12 +112,11 @@ static struct lu_kmem_descr ccc_caches[] = {
 *
 *
 */
 */


void *ccc_key_init(const struct lu_context *ctx,
void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key)
			  struct lu_context_key *key)
{
{
	struct ccc_thread_info *info;
	struct ccc_thread_info *info;


	OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, __GFP_IO);
	OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, GFP_NOFS);
	if (info == NULL)
	if (info == NULL)
		info = ERR_PTR(-ENOMEM);
		info = ERR_PTR(-ENOMEM);
	return info;
	return info;
@@ -135,7 +134,7 @@ void *ccc_session_key_init(const struct lu_context *ctx,
{
{
	struct ccc_session *session;
	struct ccc_session *session;


	OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, __GFP_IO);
	OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, GFP_NOFS);
	if (session == NULL)
	if (session == NULL)
		session = ERR_PTR(-ENOMEM);
		session = ERR_PTR(-ENOMEM);
	return session;
	return session;
@@ -251,7 +250,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev,
	struct ccc_req *vrq;
	struct ccc_req *vrq;
	int result;
	int result;


	OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, __GFP_IO);
	OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, GFP_NOFS);
	if (vrq != NULL) {
	if (vrq != NULL) {
		cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops);
		cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops);
		result = 0;
		result = 0;
@@ -327,7 +326,7 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env,
	struct ccc_object *vob;
	struct ccc_object *vob;
	struct lu_object  *obj;
	struct lu_object  *obj;


	OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, __GFP_IO);
	OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, GFP_NOFS);
	if (vob != NULL) {
	if (vob != NULL) {
		struct cl_object_header *hdr;
		struct cl_object_header *hdr;


@@ -396,7 +395,7 @@ int ccc_lock_init(const struct lu_env *env,


	CLOBINVRNT(env, obj, ccc_object_invariant(obj));
	CLOBINVRNT(env, obj, ccc_object_invariant(obj));


	OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, __GFP_IO);
	OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, GFP_NOFS);
	if (clk != NULL) {
	if (clk != NULL) {
		cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops);
		cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops);
		result = 0;
		result = 0;
Loading