diff mbox

[TRIVIAL] ceph: Free the previous caps if alloc failed.

Message ID 201306251527405618532@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

majianpeng June 25, 2013, 7:27 a.m. UTC
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>

---
 fs/ceph/caps.c | 5 +++++
 1 file changed, 5 insertions(+)

-- 
1.8.1.2

Comments

Sage Weil June 25, 2013, 3:27 p.m. UTC | #1
I think in this case we don't want to drop other caps.  This basically 
means we weren't able to maintain the desired level of reserves, but we 
will continue to try to fill it periodically, and not reaching the desired 
point is not a reason to throw out what we have.  You'll note that the one 
caller ignores the return value..

sage


On Tue, 25 Jun 2013, majianpeng wrote:

> Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
> ---
>  fs/ceph/caps.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index da0f9b8..626b0ec 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -203,6 +203,11 @@ out_alloc_count:
>  	/* we didn't manage to reserve as much as we needed */
>  	pr_warning("reserve caps ctx=%p ENOMEM need=%d got=%d\n",
>  		   ctx, need, have);
> +	if (alloc) {
> +		struct ceph_cap *tmp;
> +		list_for_each_entry_safe(cap, tmp, &newcaps, caps_item)
> +			kmem_cache_free(ceph_cap_cachep, cap);
> +	}
>  	return ret;
>  }
>  
> -- 
> 1.8.1.2
> 
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index da0f9b8..626b0ec 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -203,6 +203,11 @@  out_alloc_count:
 	/* we didn't manage to reserve as much as we needed */
 	pr_warning("reserve caps ctx=%p ENOMEM need=%d got=%d\n",
 		   ctx, need, have);
+	if (alloc) {
+		struct ceph_cap *tmp;
+		list_for_each_entry_safe(cap, tmp, &newcaps, caps_item)
+			kmem_cache_free(ceph_cap_cachep, cap);
+	}
 	return ret;
 }