All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: set up page array mempool with correct size
@ 2013-04-01 15:49 Alex Elder
  2013-04-03 18:50 ` Josh Durgin
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2013-04-01 15:49 UTC (permalink / raw)
  To: ceph-devel@vger.kernel.org

In create_fs_client() a memory pool is set up be used for arrays of
pages that might be needed in ceph_writepages_start() if memory is
tight.  There are two problems with the way it's initialized:
    - The size provided is the number of pages we want in the
      array, but it should be the number of bytes required for
      that many page pointers.
    - The number of pages computed can end up being 0, while we
      will always need at least one page.

This patch fixes both of these problems.

This resolves the two simple problems defined in:
    http://tracker.ceph.com/issues/4603

Signed-off-by: Alex Elder <elder@inktank.com>
---
 fs/ceph/super.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 9fe17c6c..318bee0 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -479,6 +479,8 @@ static struct ceph_fs_client
*create_fs_client(struct ceph_mount_options *fsopt,
 		CEPH_FEATURE_FLOCK |
 		CEPH_FEATURE_DIRLAYOUTHASH;
 	const unsigned required_features = 0;
+	int page_count;
+	size_t size;
 	int err = -ENOMEM;

 	fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
@@ -522,8 +524,9 @@ static struct ceph_fs_client
*create_fs_client(struct ceph_mount_options *fsopt,

 	/* set up mempools */
 	err = -ENOMEM;
-	fsc->wb_pagevec_pool = mempool_create_kmalloc_pool(10,
-			      fsc->mount_options->wsize >> PAGE_CACHE_SHIFT);
+	page_count = fsc->mount_options->wsize >> PAGE_CACHE_SHIFT;
+	size = sizeof (struct page *) * (page_count ? page_count : 1);
+	fsc->wb_pagevec_pool = mempool_create_kmalloc_pool(10, size);
 	if (!fsc->wb_pagevec_pool)
 		goto fail_trunc_wq;

-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: set up page array mempool with correct size
  2013-04-01 15:49 [PATCH] ceph: set up page array mempool with correct size Alex Elder
@ 2013-04-03 18:50 ` Josh Durgin
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Durgin @ 2013-04-03 18:50 UTC (permalink / raw)
  To: Alex Elder; +Cc: ceph-devel@vger.kernel.org

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 04/01/2013 08:49 AM, Alex Elder wrote:
> In create_fs_client() a memory pool is set up be used for arrays of
> pages that might be needed in ceph_writepages_start() if memory is
> tight.  There are two problems with the way it's initialized:
>      - The size provided is the number of pages we want in the
>        array, but it should be the number of bytes required for
>        that many page pointers.
>      - The number of pages computed can end up being 0, while we
>        will always need at least one page.
>
> This patch fixes both of these problems.
>
> This resolves the two simple problems defined in:
>      http://tracker.ceph.com/issues/4603
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   fs/ceph/super.c |    7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index 9fe17c6c..318bee0 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -479,6 +479,8 @@ static struct ceph_fs_client
> *create_fs_client(struct ceph_mount_options *fsopt,
>   		CEPH_FEATURE_FLOCK |
>   		CEPH_FEATURE_DIRLAYOUTHASH;
>   	const unsigned required_features = 0;
> +	int page_count;
> +	size_t size;
>   	int err = -ENOMEM;
>
>   	fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
> @@ -522,8 +524,9 @@ static struct ceph_fs_client
> *create_fs_client(struct ceph_mount_options *fsopt,
>
>   	/* set up mempools */
>   	err = -ENOMEM;
> -	fsc->wb_pagevec_pool = mempool_create_kmalloc_pool(10,
> -			      fsc->mount_options->wsize >> PAGE_CACHE_SHIFT);
> +	page_count = fsc->mount_options->wsize >> PAGE_CACHE_SHIFT;
> +	size = sizeof (struct page *) * (page_count ? page_count : 1);
> +	fsc->wb_pagevec_pool = mempool_create_kmalloc_pool(10, size);
>   	if (!fsc->wb_pagevec_pool)
>   		goto fail_trunc_wq;
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-03 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01 15:49 [PATCH] ceph: set up page array mempool with correct size Alex Elder
2013-04-03 18:50 ` Josh Durgin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.