summaryrefslogtreecommitdiffstats
path: root/fs/quota/dquot.c
diff options
context:
space:
mode:
authorBaokun Li <libaokun1@huawei.com>2023-06-30 13:08:18 +0200
committerJan Kara <jack@suse.cz>2023-07-03 19:00:19 +0200
commit024128477809f8073d870307c8157b8826ebfd08 (patch)
treefe6b8785f5d9fdea686dca75824f146931c1ef79 /fs/quota/dquot.c
parentext2: remove redundant assignment to variable desc and variable best_desc (diff)
downloadlinux-024128477809f8073d870307c8157b8826ebfd08.tar.xz
linux-024128477809f8073d870307c8157b8826ebfd08.zip
quota: factor out dquot_write_dquot()
Refactor out dquot_write_dquot() to reduce duplicate code. Signed-off-by: Baokun Li <libaokun1@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20230630110822.3881712-2-libaokun1@huawei.com>
Diffstat (limited to '')
-rw-r--r--fs/quota/dquot.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index e3e4f4047657..108ba9f1e420 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -628,6 +628,18 @@ out:
}
EXPORT_SYMBOL(dquot_scan_active);
+static inline int dquot_write_dquot(struct dquot *dquot)
+{
+ int ret = dquot->dq_sb->dq_op->write_dquot(dquot);
+ if (ret < 0) {
+ quota_error(dquot->dq_sb, "Can't write quota structure "
+ "(error %d). Quota may get out of sync!", ret);
+ /* Clear dirty bit anyway to avoid infinite loop. */
+ clear_dquot_dirty(dquot);
+ }
+ return ret;
+}
+
/* Write all dquot structures to quota files */
int dquot_writeback_dquots(struct super_block *sb, int type)
{
@@ -658,16 +670,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
* use count */
dqgrab(dquot);
spin_unlock(&dq_list_lock);
- err = sb->dq_op->write_dquot(dquot);
- if (err) {
- /*
- * Clear dirty bit anyway to avoid infinite
- * loop here.
- */
- clear_dquot_dirty(dquot);
- if (!ret)
- ret = err;
- }
+ err = dquot_write_dquot(dquot);
+ if (err && !ret)
+ ret = err;
dqput(dquot);
spin_lock(&dq_list_lock);
}
@@ -765,8 +770,6 @@ static struct shrinker dqcache_shrinker = {
*/
void dqput(struct dquot *dquot)
{
- int ret;
-
if (!dquot)
return;
#ifdef CONFIG_QUOTA_DEBUG
@@ -794,17 +797,7 @@ we_slept:
if (dquot_dirty(dquot)) {
spin_unlock(&dq_list_lock);
/* Commit dquot before releasing */
- ret = dquot->dq_sb->dq_op->write_dquot(dquot);
- if (ret < 0) {
- quota_error(dquot->dq_sb, "Can't write quota structure"
- " (error %d). Quota may get out of sync!",
- ret);
- /*
- * We clear dirty bit anyway, so that we avoid
- * infinite loop here
- */
- clear_dquot_dirty(dquot);
- }
+ dquot_write_dquot(dquot);
goto we_slept;
}
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {