diff options
author | Yehuda Sadeh <yehuda@hq.newdream.net> | 2010-04-06 17:33:58 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:42 -0400 |
commit | 34d23762d988b7dcb08390ac72a353df3d60193c (patch) | |
tree | 3a49d039527548697165da2b8789f3588b95ffed | |
parent | 23804d91f112df09b832cd091b71af4dc2831aa8 (diff) |
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: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | fs/ceph/caps.c | 2 | ||||
-rw-r--r-- | fs/ceph/file.c | 10 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 11 | ||||
-rw-r--r-- | fs/ceph/messenger.c | 10 | ||||
-rw-r--r-- | fs/ceph/messenger.h | 2 | ||||
-rw-r--r-- | fs/ceph/mon_client.c | 15 | ||||
-rw-r--r-- | fs/ceph/msgpool.c | 4 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 8 |
8 files changed, 32 insertions, 30 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 0e85d3c80790..0dd0b81e64f7 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -938,7 +938,7 @@ static int send_cap_msg(struct ceph_mds_session *session, | |||
938 | seq, issue_seq, mseq, follows, size, max_size, | 938 | seq, issue_seq, mseq, follows, size, max_size, |
939 | xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); | 939 | xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); |
940 | 940 | ||
941 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc)); | 941 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), GFP_NOFS); |
942 | if (!msg) | 942 | if (!msg) |
943 | return -ENOMEM; | 943 | return -ENOMEM; |
944 | 944 | ||
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index b0426090e8c3..0611ec3698aa 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -317,16 +317,16 @@ void ceph_release_page_vector(struct page **pages, int num_pages) | |||
317 | /* | 317 | /* |
318 | * allocate a vector new pages | 318 | * allocate a vector new pages |
319 | */ | 319 | */ |
320 | static struct page **alloc_page_vector(int num_pages) | 320 | struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags) |
321 | { | 321 | { |
322 | struct page **pages; | 322 | struct page **pages; |
323 | int i; | 323 | int i; |
324 | 324 | ||
325 | pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS); | 325 | pages = kmalloc(sizeof(*pages) * num_pages, flags); |
326 | if (!pages) | 326 | if (!pages) |
327 | return ERR_PTR(-ENOMEM); | 327 | return ERR_PTR(-ENOMEM); |
328 | for (i = 0; i < num_pages; i++) { | 328 | for (i = 0; i < num_pages; i++) { |
329 | pages[i] = __page_cache_alloc(GFP_NOFS); | 329 | pages[i] = __page_cache_alloc(flags); |
330 | if (pages[i] == NULL) { | 330 | if (pages[i] == NULL) { |
331 | ceph_release_page_vector(pages, i); | 331 | ceph_release_page_vector(pages, i); |
332 | return ERR_PTR(-ENOMEM); | 332 | return ERR_PTR(-ENOMEM); |
@@ -540,7 +540,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data, | |||
540 | * in sequence. | 540 | * in sequence. |
541 | */ | 541 | */ |
542 | } else { | 542 | } else { |
543 | pages = alloc_page_vector(num_pages); | 543 | pages = ceph_alloc_page_vector(num_pages, GFP_NOFS); |
544 | } | 544 | } |
545 | if (IS_ERR(pages)) | 545 | if (IS_ERR(pages)) |
546 | return PTR_ERR(pages); | 546 | return PTR_ERR(pages); |
@@ -668,7 +668,7 @@ more: | |||
668 | truncate_inode_pages_range(inode->i_mapping, pos, | 668 | truncate_inode_pages_range(inode->i_mapping, pos, |
669 | (pos+len) | (PAGE_CACHE_SIZE-1)); | 669 | (pos+len) | (PAGE_CACHE_SIZE-1)); |
670 | } else { | 670 | } else { |
671 | pages = alloc_page_vector(num_pages); | 671 | pages = ceph_alloc_page_vector(num_pages, GFP_NOFS); |
672 | if (IS_ERR(pages)) { | 672 | if (IS_ERR(pages)) { |
673 | ret = PTR_ERR(pages); | 673 | ret = PTR_ERR(pages); |
674 | goto out; | 674 | goto out; |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 5c17ab44d02d..1b786cf2c7af 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -665,7 +665,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq) | |||
665 | struct ceph_msg *msg; | 665 | struct ceph_msg *msg; |
666 | struct ceph_mds_session_head *h; | 666 | struct ceph_mds_session_head *h; |
667 | 667 | ||
668 | msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h)); | 668 | msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), GFP_NOFS); |
669 | if (!msg) { | 669 | if (!msg) { |
670 | pr_err("create_session_msg ENOMEM creating msg\n"); | 670 | pr_err("create_session_msg ENOMEM creating msg\n"); |
671 | return NULL; | 671 | return NULL; |
@@ -1089,7 +1089,8 @@ static int add_cap_releases(struct ceph_mds_client *mdsc, | |||
1089 | 1089 | ||
1090 | while (session->s_num_cap_releases < session->s_nr_caps + extra) { | 1090 | while (session->s_num_cap_releases < session->s_nr_caps + extra) { |
1091 | spin_unlock(&session->s_cap_lock); | 1091 | spin_unlock(&session->s_cap_lock); |
1092 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE); | 1092 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE, |
1093 | GFP_NOFS); | ||
1093 | if (!msg) | 1094 | if (!msg) |
1094 | goto out_unlocked; | 1095 | goto out_unlocked; |
1095 | dout("add_cap_releases %p msg %p now %d\n", session, msg, | 1096 | 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, | |||
1492 | if (req->r_old_dentry_drop) | 1493 | if (req->r_old_dentry_drop) |
1493 | len += req->r_old_dentry->d_name.len; | 1494 | len += req->r_old_dentry->d_name.len; |
1494 | 1495 | ||
1495 | msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len); | 1496 | msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, GFP_NOFS); |
1496 | if (!msg) { | 1497 | if (!msg) { |
1497 | msg = ERR_PTR(-ENOMEM); | 1498 | msg = ERR_PTR(-ENOMEM); |
1498 | goto out_free2; | 1499 | goto out_free2; |
@@ -2244,7 +2245,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, | |||
2244 | goto fail_nopagelist; | 2245 | goto fail_nopagelist; |
2245 | ceph_pagelist_init(pagelist); | 2246 | ceph_pagelist_init(pagelist); |
2246 | 2247 | ||
2247 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0); | 2248 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, GFP_NOFS); |
2248 | if (!reply) | 2249 | if (!reply) |
2249 | goto fail_nomsg; | 2250 | goto fail_nomsg; |
2250 | 2251 | ||
@@ -2535,7 +2536,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session, | |||
2535 | dnamelen = dentry->d_name.len; | 2536 | dnamelen = dentry->d_name.len; |
2536 | len += dnamelen; | 2537 | len += dnamelen; |
2537 | 2538 | ||
2538 | msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len); | 2539 | msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS); |
2539 | if (!msg) | 2540 | if (!msg) |
2540 | return; | 2541 | return; |
2541 | lease = msg->front.iov_base; | 2542 | lease = msg->front.iov_base; |
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index 50c5f24086fd..60b74839ebec 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -2070,11 +2070,11 @@ void ceph_con_keepalive(struct ceph_connection *con) | |||
2070 | * construct a new message with given type, size | 2070 | * construct a new message with given type, size |
2071 | * the new msg has a ref count of 1. | 2071 | * the new msg has a ref count of 1. |
2072 | */ | 2072 | */ |
2073 | struct ceph_msg *ceph_msg_new(int type, int front_len) | 2073 | struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) |
2074 | { | 2074 | { |
2075 | struct ceph_msg *m; | 2075 | struct ceph_msg *m; |
2076 | 2076 | ||
2077 | m = kmalloc(sizeof(*m), GFP_NOFS); | 2077 | m = kmalloc(sizeof(*m), flags); |
2078 | if (m == NULL) | 2078 | if (m == NULL) |
2079 | goto out; | 2079 | goto out; |
2080 | kref_init(&m->kref); | 2080 | kref_init(&m->kref); |
@@ -2101,11 +2101,11 @@ struct ceph_msg *ceph_msg_new(int type, int front_len) | |||
2101 | /* front */ | 2101 | /* front */ |
2102 | if (front_len) { | 2102 | if (front_len) { |
2103 | if (front_len > PAGE_CACHE_SIZE) { | 2103 | if (front_len > PAGE_CACHE_SIZE) { |
2104 | m->front.iov_base = __vmalloc(front_len, GFP_NOFS, | 2104 | m->front.iov_base = __vmalloc(front_len, flags, |
2105 | PAGE_KERNEL); | 2105 | PAGE_KERNEL); |
2106 | m->front_is_vmalloc = true; | 2106 | m->front_is_vmalloc = true; |
2107 | } else { | 2107 | } else { |
2108 | m->front.iov_base = kmalloc(front_len, GFP_NOFS); | 2108 | m->front.iov_base = kmalloc(front_len, flags); |
2109 | } | 2109 | } |
2110 | if (m->front.iov_base == NULL) { | 2110 | if (m->front.iov_base == NULL) { |
2111 | pr_err("msg_new can't allocate %d bytes\n", | 2111 | 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, | |||
2180 | } | 2180 | } |
2181 | if (!msg) { | 2181 | if (!msg) { |
2182 | *skip = 0; | 2182 | *skip = 0; |
2183 | msg = ceph_msg_new(type, front_len); | 2183 | msg = ceph_msg_new(type, front_len, GFP_NOFS); |
2184 | if (!msg) { | 2184 | if (!msg) { |
2185 | pr_err("unable to allocate msg type %d len %d\n", | 2185 | pr_err("unable to allocate msg type %d len %d\n", |
2186 | type, front_len); | 2186 | type, front_len); |
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h index 889f81f093c9..00a9430b1ffc 100644 --- a/fs/ceph/messenger.h +++ b/fs/ceph/messenger.h | |||
@@ -232,7 +232,7 @@ extern void ceph_con_keepalive(struct ceph_connection *con); | |||
232 | extern struct ceph_connection *ceph_con_get(struct ceph_connection *con); | 232 | extern struct ceph_connection *ceph_con_get(struct ceph_connection *con); |
233 | extern void ceph_con_put(struct ceph_connection *con); | 233 | extern void ceph_con_put(struct ceph_connection *con); |
234 | 234 | ||
235 | extern struct ceph_msg *ceph_msg_new(int type, int front_len); | 235 | extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags); |
236 | extern void ceph_msg_kfree(struct ceph_msg *m); | 236 | extern void ceph_msg_kfree(struct ceph_msg *m); |
237 | 237 | ||
238 | 238 | ||
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c index 7062b889ab2f..61cb11701f10 100644 --- a/fs/ceph/mon_client.c +++ b/fs/ceph/mon_client.c | |||
@@ -191,7 +191,7 @@ static void __send_subscribe(struct ceph_mon_client *monc) | |||
191 | struct ceph_mon_subscribe_item *i; | 191 | struct ceph_mon_subscribe_item *i; |
192 | void *p, *end; | 192 | void *p, *end; |
193 | 193 | ||
194 | msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96); | 194 | msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS); |
195 | if (!msg) | 195 | if (!msg) |
196 | return; | 196 | return; |
197 | 197 | ||
@@ -490,10 +490,10 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) | |||
490 | init_completion(&req->completion); | 490 | init_completion(&req->completion); |
491 | 491 | ||
492 | err = -ENOMEM; | 492 | err = -ENOMEM; |
493 | req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h)); | 493 | req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS); |
494 | if (!req->request) | 494 | if (!req->request) |
495 | goto out; | 495 | goto out; |
496 | req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024); | 496 | req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, GFP_NOFS); |
497 | if (!req->reply) | 497 | if (!req->reply) |
498 | goto out; | 498 | goto out; |
499 | 499 | ||
@@ -632,15 +632,16 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) | |||
632 | /* msg pools */ | 632 | /* msg pools */ |
633 | err = -ENOMEM; | 633 | err = -ENOMEM; |
634 | monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, | 634 | monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, |
635 | sizeof(struct ceph_mon_subscribe_ack)); | 635 | sizeof(struct ceph_mon_subscribe_ack), |
636 | GFP_NOFS); | ||
636 | if (!monc->m_subscribe_ack) | 637 | if (!monc->m_subscribe_ack) |
637 | goto out_monmap; | 638 | goto out_monmap; |
638 | 639 | ||
639 | monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096); | 640 | monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS); |
640 | if (!monc->m_auth_reply) | 641 | if (!monc->m_auth_reply) |
641 | goto out_subscribe_ack; | 642 | goto out_subscribe_ack; |
642 | 643 | ||
643 | monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096); | 644 | monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS); |
644 | monc->pending_auth = 0; | 645 | monc->pending_auth = 0; |
645 | if (!monc->m_auth) | 646 | if (!monc->m_auth) |
646 | goto out_auth_reply; | 647 | goto out_auth_reply; |
@@ -815,7 +816,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con, | |||
815 | case CEPH_MSG_MON_MAP: | 816 | case CEPH_MSG_MON_MAP: |
816 | case CEPH_MSG_MDS_MAP: | 817 | case CEPH_MSG_MDS_MAP: |
817 | case CEPH_MSG_OSD_MAP: | 818 | case CEPH_MSG_OSD_MAP: |
818 | m = ceph_msg_new(type, front_len); | 819 | m = ceph_msg_new(type, front_len, GFP_NOFS); |
819 | break; | 820 | break; |
820 | } | 821 | } |
821 | 822 | ||
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c index 50fe5cc5de76..dd65a6438131 100644 --- a/fs/ceph/msgpool.c +++ b/fs/ceph/msgpool.c | |||
@@ -12,7 +12,7 @@ static void *alloc_fn(gfp_t gfp_mask, void *arg) | |||
12 | struct ceph_msgpool *pool = arg; | 12 | struct ceph_msgpool *pool = arg; |
13 | void *p; | 13 | void *p; |
14 | 14 | ||
15 | p = ceph_msg_new(0, pool->front_len); | 15 | p = ceph_msg_new(0, pool->front_len, gfp_mask); |
16 | if (!p) | 16 | if (!p) |
17 | pr_err("msgpool %s alloc failed\n", pool->name); | 17 | pr_err("msgpool %s alloc failed\n", pool->name); |
18 | return p; | 18 | return p; |
@@ -48,7 +48,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, | |||
48 | WARN_ON(1); | 48 | WARN_ON(1); |
49 | 49 | ||
50 | /* try to alloc a fresh message */ | 50 | /* try to alloc a fresh message */ |
51 | return ceph_msg_new(0, front_len); | 51 | return ceph_msg_new(0, front_len, GFP_NOFS); |
52 | } | 52 | } |
53 | 53 | ||
54 | return mempool_alloc(pool->pool, GFP_NOFS); | 54 | return mempool_alloc(pool->pool, GFP_NOFS); |
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index c0aca732efd3..16141e6e8b73 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -164,7 +164,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
164 | msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0); | 164 | msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0); |
165 | else | 165 | else |
166 | msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, | 166 | msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, |
167 | OSD_OPREPLY_FRONT_LEN); | 167 | OSD_OPREPLY_FRONT_LEN, GFP_NOFS); |
168 | if (!msg) { | 168 | if (!msg) { |
169 | ceph_osdc_put_request(req); | 169 | ceph_osdc_put_request(req); |
170 | return NULL; | 170 | return NULL; |
@@ -178,7 +178,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
178 | if (use_mempool) | 178 | if (use_mempool) |
179 | msg = ceph_msgpool_get(&osdc->msgpool_op, 0); | 179 | msg = ceph_msgpool_get(&osdc->msgpool_op, 0); |
180 | else | 180 | else |
181 | msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size); | 181 | msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, GFP_NOFS); |
182 | if (!msg) { | 182 | if (!msg) { |
183 | ceph_osdc_put_request(req); | 183 | ceph_osdc_put_request(req); |
184 | return NULL; | 184 | return NULL; |
@@ -1395,7 +1395,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, | |||
1395 | if (front > req->r_reply->front.iov_len) { | 1395 | if (front > req->r_reply->front.iov_len) { |
1396 | pr_warning("get_reply front %d > preallocated %d\n", | 1396 | pr_warning("get_reply front %d > preallocated %d\n", |
1397 | front, (int)req->r_reply->front.iov_len); | 1397 | front, (int)req->r_reply->front.iov_len); |
1398 | m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front); | 1398 | m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front, GFP_NOFS); |
1399 | if (!m) | 1399 | if (!m) |
1400 | goto out; | 1400 | goto out; |
1401 | ceph_msg_put(req->r_reply); | 1401 | ceph_msg_put(req->r_reply); |
@@ -1438,7 +1438,7 @@ static struct ceph_msg *alloc_msg(struct ceph_connection *con, | |||
1438 | 1438 | ||
1439 | switch (type) { | 1439 | switch (type) { |
1440 | case CEPH_MSG_OSD_MAP: | 1440 | case CEPH_MSG_OSD_MAP: |
1441 | return ceph_msg_new(type, front); | 1441 | return ceph_msg_new(type, front, GFP_NOFS); |
1442 | case CEPH_MSG_OSD_OPREPLY: | 1442 | case CEPH_MSG_OSD_OPREPLY: |
1443 | return get_reply(con, hdr, skip); | 1443 | return get_reply(con, hdr, skip); |
1444 | default: | 1444 | default: |