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

Commit 34d23762 authored by Yehuda Sadeh's avatar Yehuda Sadeh Committed by Sage Weil
Browse files

ceph: all allocation functions should get gfp_mask



This is essential, as for the rados block device we'll need
to run in different contexts that would need flags that
are other than GFP_NOFS.

Signed-off-by: default avatarYehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent 23804d91
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -938,7 +938,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
	     seq, issue_seq, mseq, follows, size, max_size,
	     seq, issue_seq, mseq, follows, size, max_size,
	     xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);
	     xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);


	msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc));
	msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), GFP_NOFS);
	if (!msg)
	if (!msg)
		return -ENOMEM;
		return -ENOMEM;


+5 −5
Original line number Original line Diff line number Diff line
@@ -317,16 +317,16 @@ void ceph_release_page_vector(struct page **pages, int num_pages)
/*
/*
 * allocate a vector new pages
 * allocate a vector new pages
 */
 */
static struct page **alloc_page_vector(int num_pages)
struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
{
{
	struct page **pages;
	struct page **pages;
	int i;
	int i;


	pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
	pages = kmalloc(sizeof(*pages) * num_pages, flags);
	if (!pages)
	if (!pages)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);
	for (i = 0; i < num_pages; i++) {
	for (i = 0; i < num_pages; i++) {
		pages[i] = __page_cache_alloc(GFP_NOFS);
		pages[i] = __page_cache_alloc(flags);
		if (pages[i] == NULL) {
		if (pages[i] == NULL) {
			ceph_release_page_vector(pages, i);
			ceph_release_page_vector(pages, i);
			return ERR_PTR(-ENOMEM);
			return ERR_PTR(-ENOMEM);
@@ -540,7 +540,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data,
		 * in sequence.
		 * in sequence.
		 */
		 */
	} else {
	} else {
		pages = alloc_page_vector(num_pages);
		pages = ceph_alloc_page_vector(num_pages, GFP_NOFS);
	}
	}
	if (IS_ERR(pages))
	if (IS_ERR(pages))
		return PTR_ERR(pages);
		return PTR_ERR(pages);
@@ -668,7 +668,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
		truncate_inode_pages_range(inode->i_mapping, pos, 
		truncate_inode_pages_range(inode->i_mapping, pos, 
					   (pos+len) | (PAGE_CACHE_SIZE-1));
					   (pos+len) | (PAGE_CACHE_SIZE-1));
	} else {
	} else {
		pages = alloc_page_vector(num_pages);
		pages = ceph_alloc_page_vector(num_pages, GFP_NOFS);
		if (IS_ERR(pages)) {
		if (IS_ERR(pages)) {
			ret = PTR_ERR(pages);
			ret = PTR_ERR(pages);
			goto out;
			goto out;
+6 −5
Original line number Original line Diff line number Diff line
@@ -665,7 +665,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)
	struct ceph_msg *msg;
	struct ceph_msg *msg;
	struct ceph_mds_session_head *h;
	struct ceph_mds_session_head *h;


	msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h));
	msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), GFP_NOFS);
	if (!msg) {
	if (!msg) {
		pr_err("create_session_msg ENOMEM creating msg\n");
		pr_err("create_session_msg ENOMEM creating msg\n");
		return NULL;
		return NULL;
@@ -1089,7 +1089,8 @@ static int add_cap_releases(struct ceph_mds_client *mdsc,


	while (session->s_num_cap_releases < session->s_nr_caps + extra) {
	while (session->s_num_cap_releases < session->s_nr_caps + extra) {
		spin_unlock(&session->s_cap_lock);
		spin_unlock(&session->s_cap_lock);
		msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE);
		msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE,
				   GFP_NOFS);
		if (!msg)
		if (!msg)
			goto out_unlocked;
			goto out_unlocked;
		dout("add_cap_releases %p msg %p now %d\n", session, msg,
		dout("add_cap_releases %p msg %p now %d\n", session, msg,
@@ -1492,7 +1493,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
	if (req->r_old_dentry_drop)
	if (req->r_old_dentry_drop)
		len += req->r_old_dentry->d_name.len;
		len += req->r_old_dentry->d_name.len;


	msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, GFP_NOFS);
	if (!msg) {
	if (!msg) {
		msg = ERR_PTR(-ENOMEM);
		msg = ERR_PTR(-ENOMEM);
		goto out_free2;
		goto out_free2;
@@ -2244,7 +2245,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
		goto fail_nopagelist;
		goto fail_nopagelist;
	ceph_pagelist_init(pagelist);
	ceph_pagelist_init(pagelist);


	reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0);
	reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, GFP_NOFS);
	if (!reply)
	if (!reply)
		goto fail_nomsg;
		goto fail_nomsg;


@@ -2535,7 +2536,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
	dnamelen = dentry->d_name.len;
	dnamelen = dentry->d_name.len;
	len += dnamelen;
	len += dnamelen;


	msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS);
	if (!msg)
	if (!msg)
		return;
		return;
	lease = msg->front.iov_base;
	lease = msg->front.iov_base;
+5 −5
Original line number Original line Diff line number Diff line
@@ -2070,11 +2070,11 @@ void ceph_con_keepalive(struct ceph_connection *con)
 * construct a new message with given type, size
 * construct a new message with given type, size
 * the new msg has a ref count of 1.
 * the new msg has a ref count of 1.
 */
 */
struct ceph_msg *ceph_msg_new(int type, int front_len)
struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
{
{
	struct ceph_msg *m;
	struct ceph_msg *m;


	m = kmalloc(sizeof(*m), GFP_NOFS);
	m = kmalloc(sizeof(*m), flags);
	if (m == NULL)
	if (m == NULL)
		goto out;
		goto out;
	kref_init(&m->kref);
	kref_init(&m->kref);
@@ -2101,11 +2101,11 @@ struct ceph_msg *ceph_msg_new(int type, int front_len)
	/* front */
	/* front */
	if (front_len) {
	if (front_len) {
		if (front_len > PAGE_CACHE_SIZE) {
		if (front_len > PAGE_CACHE_SIZE) {
			m->front.iov_base = __vmalloc(front_len, GFP_NOFS,
			m->front.iov_base = __vmalloc(front_len, flags,
						      PAGE_KERNEL);
						      PAGE_KERNEL);
			m->front_is_vmalloc = true;
			m->front_is_vmalloc = true;
		} else {
		} else {
			m->front.iov_base = kmalloc(front_len, GFP_NOFS);
			m->front.iov_base = kmalloc(front_len, flags);
		}
		}
		if (m->front.iov_base == NULL) {
		if (m->front.iov_base == NULL) {
			pr_err("msg_new can't allocate %d bytes\n",
			pr_err("msg_new can't allocate %d bytes\n",
@@ -2180,7 +2180,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
	}
	}
	if (!msg) {
	if (!msg) {
		*skip = 0;
		*skip = 0;
		msg = ceph_msg_new(type, front_len);
		msg = ceph_msg_new(type, front_len, GFP_NOFS);
		if (!msg) {
		if (!msg) {
			pr_err("unable to allocate msg type %d len %d\n",
			pr_err("unable to allocate msg type %d len %d\n",
			       type, front_len);
			       type, front_len);
+1 −1
Original line number Original line Diff line number Diff line
@@ -232,7 +232,7 @@ extern void ceph_con_keepalive(struct ceph_connection *con);
extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
extern void ceph_con_put(struct ceph_connection *con);
extern void ceph_con_put(struct ceph_connection *con);


extern struct ceph_msg *ceph_msg_new(int type, int front_len);
extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags);
extern void ceph_msg_kfree(struct ceph_msg *m);
extern void ceph_msg_kfree(struct ceph_msg *m);




Loading