mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
ocfs2/dlm: replace __get_free_page() with kmalloc()
A few places in ocsfs2 allocate temporary buffers with __get_free_page() or get_zeroed_page(). kmalloc() is a better API for such use and it also provides better scalability and more debugging possibilities. Replace use of __get_free_page() and get_zeroed_page() with kmalloc() and kzalloc() respectively. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Link: https://patch.msgid.link/20260523-b4-fs-v1-3-275e36a83f0e@kernel.org Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
cb7907e36c
commit
bc24c55579
|
|
@ -260,10 +260,10 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle)
|
|||
{
|
||||
char *buf;
|
||||
|
||||
buf = (char *) get_zeroed_page(GFP_ATOMIC);
|
||||
buf = kzalloc(PAGE_SIZE, GFP_ATOMIC);
|
||||
if (buf) {
|
||||
dump_mle(mle, buf, PAGE_SIZE - 1);
|
||||
free_page((unsigned long)buf);
|
||||
kfree(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ static struct dentry *dlm_debugfs_root;
|
|||
/* begin - utils funcs */
|
||||
static int debug_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
free_page((unsigned long)file->private_data);
|
||||
kfree(file->private_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -327,17 +327,15 @@ static int debug_purgelist_open(struct inode *inode, struct file *file)
|
|||
struct dlm_ctxt *dlm = inode->i_private;
|
||||
char *buf = NULL;
|
||||
|
||||
buf = (char *) get_zeroed_page(GFP_NOFS);
|
||||
buf = kzalloc(PAGE_SIZE, GFP_NOFS);
|
||||
if (!buf)
|
||||
goto bail;
|
||||
return -ENOMEM;
|
||||
|
||||
i_size_write(inode, debug_purgelist_print(dlm, buf, PAGE_SIZE - 1));
|
||||
|
||||
file->private_data = buf;
|
||||
|
||||
return 0;
|
||||
bail:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static const struct file_operations debug_purgelist_fops = {
|
||||
|
|
@ -384,17 +382,15 @@ static int debug_mle_open(struct inode *inode, struct file *file)
|
|||
struct dlm_ctxt *dlm = inode->i_private;
|
||||
char *buf = NULL;
|
||||
|
||||
buf = (char *) get_zeroed_page(GFP_NOFS);
|
||||
buf = kzalloc(PAGE_SIZE, GFP_NOFS);
|
||||
if (!buf)
|
||||
goto bail;
|
||||
return -ENOMEM;
|
||||
|
||||
i_size_write(inode, debug_mle_print(dlm, buf, PAGE_SIZE - 1));
|
||||
|
||||
file->private_data = buf;
|
||||
|
||||
return 0;
|
||||
bail:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static const struct file_operations debug_mle_fops = {
|
||||
|
|
@ -775,17 +771,15 @@ static int debug_state_open(struct inode *inode, struct file *file)
|
|||
struct dlm_ctxt *dlm = inode->i_private;
|
||||
char *buf = NULL;
|
||||
|
||||
buf = (char *) get_zeroed_page(GFP_NOFS);
|
||||
buf = kzalloc(PAGE_SIZE, GFP_NOFS);
|
||||
if (!buf)
|
||||
goto bail;
|
||||
return -ENOMEM;
|
||||
|
||||
i_size_write(inode, debug_state_print(dlm, buf, PAGE_SIZE - 1));
|
||||
|
||||
file->private_data = buf;
|
||||
|
||||
return 0;
|
||||
bail:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static const struct file_operations debug_state_fops = {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static inline void byte_copymap(u8 dmap[], unsigned long smap[],
|
|||
static void dlm_free_pagevec(void **vec, int pages)
|
||||
{
|
||||
while (pages--)
|
||||
free_page((unsigned long)vec[pages]);
|
||||
kfree(vec[pages]);
|
||||
kfree(vec);
|
||||
}
|
||||
|
||||
|
|
@ -75,9 +75,11 @@ static void **dlm_alloc_pagevec(int pages)
|
|||
if (!vec)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < pages; i++)
|
||||
if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
|
||||
for (i = 0; i < pages; i++) {
|
||||
vec[i] = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!vec[i])
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
|
||||
pages, (unsigned long)DLM_HASH_PAGES,
|
||||
|
|
|
|||
|
|
@ -2548,7 +2548,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
|
|||
|
||||
/* preallocate up front. if this fails, abort */
|
||||
ret = -ENOMEM;
|
||||
mres = (struct dlm_migratable_lockres *) __get_free_page(GFP_NOFS);
|
||||
mres = kmalloc(PAGE_SIZE, GFP_NOFS);
|
||||
if (!mres) {
|
||||
mlog_errno(ret);
|
||||
goto leave;
|
||||
|
|
@ -2725,8 +2725,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
|
|||
if (wake)
|
||||
wake_up(&res->wq);
|
||||
|
||||
if (mres)
|
||||
free_page((unsigned long)mres);
|
||||
kfree(mres);
|
||||
|
||||
dlm_put(dlm);
|
||||
|
||||
|
|
|
|||
|
|
@ -837,7 +837,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data,
|
|||
}
|
||||
|
||||
/* this will get freed by dlm_request_all_locks_worker */
|
||||
buf = (char *) __get_free_page(GFP_NOFS);
|
||||
buf = kmalloc(PAGE_SIZE, GFP_NOFS);
|
||||
if (!buf) {
|
||||
kfree(item);
|
||||
dlm_put(dlm);
|
||||
|
|
@ -933,7 +933,7 @@ static void dlm_request_all_locks_worker(struct dlm_work_item *item, void *data)
|
|||
}
|
||||
}
|
||||
leave:
|
||||
free_page((unsigned long)data);
|
||||
kfree(data);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user