aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-03-03 18:38:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-03-04 10:55:48 -0500
commit15c34a760630ca2c803848fba90ca0646a9907dd (patch)
treea8045655ec6307ff8fc9794bd440368df51dc7f3 /fs/ocfs2
parent40d2d968e99aa267ac1e5d70deb97faa41a7dfc8 (diff)
ocfs2: fix quota file corruption
Global quota files are accessed from different nodes. Thus we cannot cache offset of quota structure in the quota file after we drop our node reference count to it because after that moment quota structure may be freed and reallocated elsewhere by a different node resulting in corruption of quota file. Fix the problem by clearing dq_off when we are releasing dquot structure. We also remove the DB_READ_B handling because it is useless - DQ_ACTIVE_B is set iff DQ_READ_B is set. Signed-off-by: Jan Kara <jack@suse.cz> Cc: Goldwyn Rodrigues <rgoldwyn@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Reviewed-by: Mark Fasheh <mfasheh@suse.de> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/quota_global.c27
-rw-r--r--fs/ocfs2/quota_local.c4
2 files changed, 17 insertions, 14 deletions
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index aaa50611ec66..d7b5108789e2 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -717,6 +717,12 @@ static int ocfs2_release_dquot(struct dquot *dquot)
717 */ 717 */
718 if (status < 0) 718 if (status < 0)
719 mlog_errno(status); 719 mlog_errno(status);
720 /*
721 * Clear dq_off so that we search for the structure in quota file next
722 * time we acquire it. The structure might be deleted and reallocated
723 * elsewhere by another node while our dquot structure is on freelist.
724 */
725 dquot->dq_off = 0;
720 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags); 726 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
721out_trans: 727out_trans:
722 ocfs2_commit_trans(osb, handle); 728 ocfs2_commit_trans(osb, handle);
@@ -756,16 +762,17 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
756 status = ocfs2_lock_global_qf(info, 1); 762 status = ocfs2_lock_global_qf(info, 1);
757 if (status < 0) 763 if (status < 0)
758 goto out; 764 goto out;
759 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) { 765 status = ocfs2_qinfo_lock(info, 0);
760 status = ocfs2_qinfo_lock(info, 0); 766 if (status < 0)
761 if (status < 0) 767 goto out_dq;
762 goto out_dq; 768 /*
763 status = qtree_read_dquot(&info->dqi_gi, dquot); 769 * We always want to read dquot structure from disk because we don't
764 ocfs2_qinfo_unlock(info, 0); 770 * know what happened with it while it was on freelist.
765 if (status < 0) 771 */
766 goto out_dq; 772 status = qtree_read_dquot(&info->dqi_gi, dquot);
767 } 773 ocfs2_qinfo_unlock(info, 0);
768 set_bit(DQ_READ_B, &dquot->dq_flags); 774 if (status < 0)
775 goto out_dq;
769 776
770 OCFS2_DQUOT(dquot)->dq_use_count++; 777 OCFS2_DQUOT(dquot)->dq_use_count++;
771 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace; 778 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 2e4344be3b96..2001862bf2b1 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -1303,10 +1303,6 @@ int ocfs2_local_release_dquot(handle_t *handle, struct dquot *dquot)
1303 ocfs2_journal_dirty(handle, od->dq_chunk->qc_headerbh); 1303 ocfs2_journal_dirty(handle, od->dq_chunk->qc_headerbh);
1304 1304
1305out: 1305out:
1306 /* Clear the read bit so that next time someone uses this
1307 * dquot he reads fresh info from disk and allocates local
1308 * dquot structure */
1309 clear_bit(DQ_READ_B, &dquot->dq_flags);
1310 return status; 1306 return status;
1311} 1307}
1312 1308