Commit ce1b06c5 authored by Zhen Lei's avatar Zhen Lei Committed by Jan Kara

quota: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory. After that, the static
function getdqbuf() becomes unnecessary, get rid of it and instead call
kmalloc() directly.

Link: https://lore.kernel.org/r/20210618014720.1977-2-thunder.leizhen@huawei.comSigned-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent e8d46b38
...@@ -47,15 +47,6 @@ static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info) ...@@ -47,15 +47,6 @@ static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
/ info->dqi_entry_size; / info->dqi_entry_size;
} }
static char *getdqbuf(size_t size)
{
char *buf = kmalloc(size, GFP_NOFS);
if (!buf)
printk(KERN_WARNING
"VFS: Not enough memory for quota buffers.\n");
return buf;
}
static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
{ {
struct super_block *sb = info->dqi_sb; struct super_block *sb = info->dqi_sb;
...@@ -83,7 +74,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) ...@@ -83,7 +74,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
/* Remove empty block from list and return it */ /* Remove empty block from list and return it */
static int get_free_dqblk(struct qtree_mem_dqinfo *info) static int get_free_dqblk(struct qtree_mem_dqinfo *info)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
int ret, blk; int ret, blk;
...@@ -132,7 +123,7 @@ static int put_free_dqblk(struct qtree_mem_dqinfo *info, char *buf, uint blk) ...@@ -132,7 +123,7 @@ static int put_free_dqblk(struct qtree_mem_dqinfo *info, char *buf, uint blk)
static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
uint blk) uint blk)
{ {
char *tmpbuf = getdqbuf(info->dqi_usable_bs); char *tmpbuf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
uint nextblk = le32_to_cpu(dh->dqdh_next_free); uint nextblk = le32_to_cpu(dh->dqdh_next_free);
uint prevblk = le32_to_cpu(dh->dqdh_prev_free); uint prevblk = le32_to_cpu(dh->dqdh_prev_free);
...@@ -179,7 +170,7 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, ...@@ -179,7 +170,7 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
uint blk) uint blk)
{ {
char *tmpbuf = getdqbuf(info->dqi_usable_bs); char *tmpbuf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
int err; int err;
...@@ -227,7 +218,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, ...@@ -227,7 +218,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
{ {
uint blk, i; uint blk, i;
struct qt_disk_dqdbheader *dh; struct qt_disk_dqdbheader *dh;
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
char *ddquot; char *ddquot;
*err = 0; *err = 0;
...@@ -298,7 +289,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, ...@@ -298,7 +289,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
uint *treeblk, int depth) uint *treeblk, int depth)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
int ret = 0, newson = 0, newact = 0; int ret = 0, newson = 0, newact = 0;
__le32 *ref; __le32 *ref;
uint newblk; uint newblk;
...@@ -375,7 +366,7 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) ...@@ -375,7 +366,7 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
int type = dquot->dq_id.type; int type = dquot->dq_id.type;
struct super_block *sb = dquot->dq_sb; struct super_block *sb = dquot->dq_sb;
ssize_t ret; ssize_t ret;
char *ddquot = getdqbuf(info->dqi_entry_size); char *ddquot = kmalloc(info->dqi_entry_size, GFP_NOFS);
if (!ddquot) if (!ddquot)
return -ENOMEM; return -ENOMEM;
...@@ -414,7 +405,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, ...@@ -414,7 +405,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
uint blk) uint blk)
{ {
struct qt_disk_dqdbheader *dh; struct qt_disk_dqdbheader *dh;
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
int ret = 0; int ret = 0;
if (!buf) if (!buf)
...@@ -474,7 +465,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, ...@@ -474,7 +465,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
uint *blk, int depth) uint *blk, int depth)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
int ret = 0; int ret = 0;
uint newblk; uint newblk;
__le32 *ref = (__le32 *)buf; __le32 *ref = (__le32 *)buf;
...@@ -533,7 +524,7 @@ EXPORT_SYMBOL(qtree_delete_dquot); ...@@ -533,7 +524,7 @@ EXPORT_SYMBOL(qtree_delete_dquot);
static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
struct dquot *dquot, uint blk) struct dquot *dquot, uint blk)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
loff_t ret = 0; loff_t ret = 0;
int i; int i;
char *ddquot; char *ddquot;
...@@ -571,7 +562,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, ...@@ -571,7 +562,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
struct dquot *dquot, uint blk, int depth) struct dquot *dquot, uint blk, int depth)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
loff_t ret = 0; loff_t ret = 0;
__le32 *ref = (__le32 *)buf; __le32 *ref = (__le32 *)buf;
...@@ -635,7 +626,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) ...@@ -635,7 +626,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
} }
dquot->dq_off = offset; dquot->dq_off = offset;
} }
ddquot = getdqbuf(info->dqi_entry_size); ddquot = kmalloc(info->dqi_entry_size, GFP_NOFS);
if (!ddquot) if (!ddquot)
return -ENOMEM; return -ENOMEM;
ret = sb->s_op->quota_read(sb, type, ddquot, info->dqi_entry_size, ret = sb->s_op->quota_read(sb, type, ddquot, info->dqi_entry_size,
...@@ -679,7 +670,7 @@ EXPORT_SYMBOL(qtree_release_dquot); ...@@ -679,7 +670,7 @@ EXPORT_SYMBOL(qtree_release_dquot);
static int find_next_id(struct qtree_mem_dqinfo *info, qid_t *id, static int find_next_id(struct qtree_mem_dqinfo *info, qid_t *id,
unsigned int blk, int depth) unsigned int blk, int depth)
{ {
char *buf = getdqbuf(info->dqi_usable_bs); char *buf = kmalloc(info->dqi_usable_bs, GFP_NOFS);
__le32 *ref = (__le32 *)buf; __le32 *ref = (__le32 *)buf;
ssize_t ret; ssize_t ret;
unsigned int epb = info->dqi_usable_bs >> 2; unsigned int epb = info->dqi_usable_bs >> 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment