From a768a9abc625d554f7b6428517089c193fcb5962 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 19 Mar 2019 09:48:59 +0100 Subject: udf: Explain handling of load_nls() failure Add comment explaining that load_nls() failure gets handled back in udf_fill_super() to avoid false impression that it is unhandled. Signed-off-by: Jan Kara --- fs/udf/super.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fs') diff --git a/fs/udf/super.c b/fs/udf/super.c index ffd8038ff728..387f90b32fa9 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -572,6 +572,11 @@ static int udf_parse_options(char *options, struct udf_options *uopt, if (!remount) { if (uopt->nls_map) unload_nls(uopt->nls_map); + /* + * load_nls() failure is handled later in + * udf_fill_super() after all options are + * parsed. + */ uopt->nls_map = load_nls(args[0].from); uopt->flags |= (1 << UDF_FLAG_NLS_MAP); } -- cgit From 1206d028b2c8f159506e0efd6dad66aca82e8de8 Mon Sep 17 00:00:00 2001 From: Shuning Zhang Date: Wed, 6 Mar 2019 09:47:35 +0800 Subject: ext2: Adjust the comment of function ext2_alloc_branch The name of argument is error in the header comment. @num should be @indirect_blks. At the same time, there was a lack of description of the two parameters @blks and @goal. This commit therefore fixes this header comment. Signed-off-by: Shuning Zhang Signed-off-by: Jan Kara --- fs/ext2/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index c27c27300d95..e474127dd255 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -451,7 +451,9 @@ failed_out: /** * ext2_alloc_branch - allocate and set up a chain of blocks. * @inode: owner - * @num: depth of the chain (number of blocks to allocate) + * @indirect_blks: depth of the chain (number of blocks to allocate) + * @blks: number of allocated direct blocks + * @goal: preferred place for allocation * @offsets: offsets (in the blocks) to store the pointers to next. * @branch: place to store the chain in. * -- cgit From df15a2a59d0b29d86e17140b83ed231adaded12f Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Wed, 20 Mar 2019 13:03:59 +0800 Subject: quota: code cleanup for __dquot_alloc_space() Replace (flags & DQUOT_SPACE_RESERVE) with variable reserve. Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/quota/dquot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs') diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba..00de508f9d2e 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1663,7 +1663,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) for (cnt = 0; cnt < MAXQUOTAS; cnt++) { if (!dquots[cnt]) continue; - if (flags & DQUOT_SPACE_RESERVE) { + if (reserve) { ret = dquot_add_space(dquots[cnt], 0, number, flags, &warn[cnt]); } else { @@ -1676,7 +1676,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) if (!dquots[cnt]) continue; spin_lock(&dquots[cnt]->dq_dqb_lock); - if (flags & DQUOT_SPACE_RESERVE) { + if (reserve) { dquots[cnt]->dq_dqb.dqb_rsvspace -= number; } else { -- cgit From 27942ef503a5e95865473c7c8c93ee9f167641cb Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 26 Mar 2019 08:54:31 +0100 Subject: quota: remove trailing whitespaces This removes all trailing whitespaces in fs/quota/. Signed-off-by: Sascha Hauer Signed-off-by: Jan Kara --- fs/quota/dquot.c | 10 +++++----- fs/quota/quota_v1.c | 2 +- fs/quota/quota_v2.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'fs') diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 00de508f9d2e..cfbf91e61ea4 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -9,7 +9,7 @@ * on the Melbourne quota system as used on BSD derived systems. The internal * implementation is based on one of the several variants of the LINUX * inode-subsystem with added complexity of the diskquota system. - * + * * Author: Marco van Wieringen * * Fixes: Dmitry Gorodchanin , 11 Feb 96 @@ -51,7 +51,7 @@ * Added journalled quota support, fix lock inversion problems * Jan Kara, , 2003,2004 * - * (C) Copyright 1994 - 1997 Marco van Wieringen + * (C) Copyright 1994 - 1997 Marco van Wieringen */ #include @@ -197,7 +197,7 @@ static struct quota_format_type *find_quota_format(int id) int qm; spin_unlock(&dq_list_lock); - + for (qm = 0; module_names[qm].qm_fmt_id && module_names[qm].qm_fmt_id != id; qm++) ; @@ -2397,7 +2397,7 @@ out_file_flags: out_fmt: put_quota_format(fmt); - return error; + return error; } /* Reenable quotas on remount RW */ @@ -2775,7 +2775,7 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state) struct qc_type_state *tstate; struct quota_info *dqopt = sb_dqopt(sb); int type; - + memset(state, 0, sizeof(*state)); for (type = 0; type < MAXQUOTAS; type++) { if (!sb_has_quota_active(sb, type)) diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c index 7ac5298aba70..9f2b2573b83c 100644 --- a/fs/quota/quota_v1.c +++ b/fs/quota/quota_v1.c @@ -127,7 +127,7 @@ static int v1_check_quota_file(struct super_block *sb, int type) { struct inode *inode = sb_dqopt(sb)->files[type]; ulong blocks; - size_t off; + size_t off; struct v2_disk_dqheader dqhead; ssize_t size; loff_t isize; diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c index a73e5b34db41..3c30034e733f 100644 --- a/fs/quota/quota_v2.c +++ b/fs/quota/quota_v2.c @@ -78,7 +78,7 @@ static int v2_check_quota_file(struct super_block *sb, int type) struct v2_disk_dqheader dqhead; static const uint quota_magics[] = V2_INITQMAGICS; static const uint quota_versions[] = V2_INITQVERSIONS; - + if (v2_read_header(sb, type, &dqhead)) return 0; if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] || -- cgit From 5d552ad79630d41ca065457e22a20ae2db5b2441 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Sun, 14 Apr 2019 16:54:38 +0530 Subject: fs/reiserfs/journal.c: Make remove_journal_hash static This fixes the -WDecl sparse warning in journal.c. Function was declared as static void but the definition was void. Signed-off-by: Bharath Vedartham Signed-off-by: Jan Kara --- fs/reiserfs/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 8a76f9d14bc6..36346dc4cec0 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -1844,7 +1844,7 @@ static int flush_used_journal_lists(struct super_block *s, * removes any nodes in table with name block and dev as bh. * only touchs the hnext and hprev pointers. */ -void remove_journal_hash(struct super_block *sb, +static void remove_journal_hash(struct super_block *sb, struct reiserfs_journal_cnode **table, struct reiserfs_journal_list *jl, unsigned long block, int remove_freed) -- cgit From 39416c5872db69859e867fa250b9cbb3f1e0d185 Mon Sep 17 00:00:00 2001 From: Wenwen Wang Date: Mon, 15 Apr 2019 12:58:06 -0500 Subject: udf: fix an uninitialized read bug and remove dead code In udf_lookup(), the pointer 'fi' is a local variable initialized by the return value of the function call udf_find_entry(). However, if the macro 'UDF_RECOVERY' is defined, this variable will become uninitialized if the else branch is not taken, which can potentially cause incorrect results in the following execution. To fix this issue, this patch drops the whole code in the ifdef 'UDF_RECOVERY' region, as it is dead code. Signed-off-by: Wenwen Wang Signed-off-by: Jan Kara --- fs/udf/namei.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'fs') diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 58cc2414992b..77b6d89b9bcd 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -304,21 +304,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, if (dentry->d_name.len > UDF_NAME_LEN) return ERR_PTR(-ENAMETOOLONG); -#ifdef UDF_RECOVERY - /* temporary shorthand for specifying files by inode number */ - if (!strncmp(dentry->d_name.name, ".B=", 3)) { - struct kernel_lb_addr lb = { - .logicalBlockNum = 0, - .partitionReferenceNum = - simple_strtoul(dentry->d_name.name + 3, - NULL, 0), - }; - inode = udf_iget(dir->i_sb, lb); - if (IS_ERR(inode)) - return inode; - } else -#endif /* UDF_RECOVERY */ - fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); if (IS_ERR(fi)) return ERR_CAST(fi); -- cgit From 3ef177ec9d5dc225bf30927a2d222d8bb1fbee0f Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Fri, 19 Apr 2019 13:46:01 +0800 Subject: quota: fix wrong indentation We need to check return code only when calling ->read_dqblk(), so fix it properly. Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/quota/dquot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index cfbf91e61ea4..d2f2972b33db 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -424,10 +424,11 @@ int dquot_acquire(struct dquot *dquot) struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); mutex_lock(&dquot->dq_lock); - if (!test_bit(DQ_READ_B, &dquot->dq_flags)) + if (!test_bit(DQ_READ_B, &dquot->dq_flags)) { ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot); - if (ret < 0) - goto out_iolock; + if (ret < 0) + goto out_iolock; + } /* Make sure flags update is visible after dquot has been filled */ smp_mb__before_atomic(); set_bit(DQ_READ_B, &dquot->dq_flags); -- cgit From 78bc3334a69ff289dbc973a9db7c52a2d7757e5b Mon Sep 17 00:00:00 2001 From: Jiang Biao Date: Wed, 24 Apr 2019 08:58:57 +0800 Subject: fs/quota: erase unused but set variable warning Local variable *reserved* of remove_dquot_ref() is only used if define CONFIG_QUOTA_DEBUG, but not ebraced in CONFIG_QUOTA_DEBUG macro, which leads to unused-but-set-variable warning when compiling. This patch ebrace it into CONFIG_QUOTA_DEBUG macro like what is done in add_dquot_ref(). Signed-off-by: Jiang Biao Signed-off-by: Jan Kara --- fs/quota/dquot.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs') diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index d2f2972b33db..67e534dbfc0e 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1050,7 +1050,9 @@ static void remove_dquot_ref(struct super_block *sb, int type, struct list_head *tofree_head) { struct inode *inode; +#ifdef CONFIG_QUOTA_DEBUG int reserved = 0; +#endif spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { @@ -1062,8 +1064,10 @@ static void remove_dquot_ref(struct super_block *sb, int type, */ spin_lock(&dq_data_lock); if (!IS_NOQUOTA(inode)) { +#ifdef CONFIG_QUOTA_DEBUG if (unlikely(inode_get_rsv_space(inode) > 0)) reserved = 1; +#endif remove_inode_dquot_ref(inode, type, tofree_head); } spin_unlock(&dq_data_lock); -- cgit From 632a9f3acd6687376cbb0b178df6048e19cbacc9 Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Tue, 30 Apr 2019 14:40:10 +0800 Subject: quota: check time limit when back out space/inode change When we fail from allocating inode/space, we back out the change we already did. In a special case which has exceeded soft limit by the change, we should also check time limit and reset it properly. Signed-off-by: Chengguang Xu Signed-off-by: Jan Kara --- fs/quota/dquot.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'fs') diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 67e534dbfc0e..9ad72ea7f71f 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1681,13 +1681,11 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) if (!dquots[cnt]) continue; spin_lock(&dquots[cnt]->dq_dqb_lock); - if (reserve) { - dquots[cnt]->dq_dqb.dqb_rsvspace -= - number; - } else { - dquots[cnt]->dq_dqb.dqb_curspace -= - number; - } + if (reserve) + dquot_free_reserved_space(dquots[cnt], + number); + else + dquot_decr_space(dquots[cnt], number); spin_unlock(&dquots[cnt]->dq_dqb_lock); } spin_unlock(&inode->i_lock); @@ -1738,7 +1736,7 @@ int dquot_alloc_inode(struct inode *inode) continue; /* Back out changes we already did */ spin_lock(&dquots[cnt]->dq_dqb_lock); - dquots[cnt]->dq_dqb.dqb_curinodes--; + dquot_decr_inodes(dquots[cnt], 1); spin_unlock(&dquots[cnt]->dq_dqb_lock); } goto warn_put_all; -- cgit