1 From: Jan Kara <jack@suse.cz>
2 References: fate#302681
3 Subject: [PATCH 28/28] ocfs2: Implement quota recovery
4 Patch-mainline: 2.6.29?
6 Implement functions for recovery after a crash. Functions just
7 read local quota file and sync info to global quota file.
9 Signed-off-by: Jan Kara <jack@suse.cz>
11 fs/ocfs2/journal.c | 103 +++++++++--
12 fs/ocfs2/journal.h | 1
14 fs/ocfs2/quota.h | 21 ++
15 fs/ocfs2/quota_local.c | 428 ++++++++++++++++++++++++++++++++++++++++++++++++-
17 6 files changed, 530 insertions(+), 30 deletions(-)
19 --- a/fs/ocfs2/journal.c
20 +++ b/fs/ocfs2/journal.c
27 #include "buffer_head_io.h"
29 @@ -52,7 +53,7 @@ DEFINE_SPINLOCK(trans_inc_lock);
31 static int ocfs2_force_read_journal(struct inode *inode);
32 static int ocfs2_recover_node(struct ocfs2_super *osb,
34 + int node_num, int slot_num);
35 static int __ocfs2_recovery_thread(void *arg);
36 static int ocfs2_commit_cache(struct ocfs2_super *osb);
37 static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota);
38 @@ -889,6 +890,7 @@ struct ocfs2_la_recovery_item {
40 struct ocfs2_dinode *lri_la_dinode;
41 struct ocfs2_dinode *lri_tl_dinode;
42 + struct ocfs2_quota_recovery *lri_qrec;
45 /* Does the second half of the recovery process. By this point, the
46 @@ -909,6 +911,7 @@ void ocfs2_complete_recovery(struct work
47 struct ocfs2_super *osb = journal->j_osb;
48 struct ocfs2_dinode *la_dinode, *tl_dinode;
49 struct ocfs2_la_recovery_item *item, *n;
50 + struct ocfs2_quota_recovery *qrec;
51 LIST_HEAD(tmp_la_list);
54 @@ -956,6 +959,16 @@ void ocfs2_complete_recovery(struct work
58 + qrec = item->lri_qrec;
60 + mlog(0, "Recovering quota files");
61 + ret = ocfs2_finish_quota_recovery(osb, qrec,
65 + /* Recovery info is already freed now */
71 @@ -969,7 +982,8 @@ void ocfs2_complete_recovery(struct work
72 static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
74 struct ocfs2_dinode *la_dinode,
75 - struct ocfs2_dinode *tl_dinode)
76 + struct ocfs2_dinode *tl_dinode,
77 + struct ocfs2_quota_recovery *qrec)
79 struct ocfs2_la_recovery_item *item;
81 @@ -984,6 +998,9 @@ static void ocfs2_queue_recovery_complet
86 + ocfs2_free_quota_recovery(qrec);
91 @@ -992,6 +1009,7 @@ static void ocfs2_queue_recovery_complet
92 item->lri_la_dinode = la_dinode;
93 item->lri_slot = slot_num;
94 item->lri_tl_dinode = tl_dinode;
95 + item->lri_qrec = qrec;
97 spin_lock(&journal->j_lock);
98 list_add_tail(&item->lri_list, &journal->j_la_cleanups);
99 @@ -1011,6 +1029,7 @@ void ocfs2_complete_mount_recovery(struc
100 ocfs2_queue_recovery_completion(journal,
102 osb->local_alloc_copy,
105 ocfs2_schedule_truncate_log_flush(osb, 0);
107 @@ -1019,11 +1038,26 @@ void ocfs2_complete_mount_recovery(struc
111 +void ocfs2_complete_quota_recovery(struct ocfs2_super *osb)
113 + if (osb->quota_rec) {
114 + ocfs2_queue_recovery_completion(osb->journal,
119 + osb->quota_rec = NULL;
123 static int __ocfs2_recovery_thread(void *arg)
125 - int status, node_num;
126 + int status, node_num, slot_num;
127 struct ocfs2_super *osb = arg;
128 struct ocfs2_recovery_map *rm = osb->recovery_map;
129 + int *rm_quota = NULL;
130 + int rm_quota_used = 0, i;
131 + struct ocfs2_quota_recovery *qrec;
135 @@ -1032,6 +1066,11 @@ static int __ocfs2_recovery_thread(void
139 + rm_quota = kzalloc(osb->max_slots * sizeof(int), GFP_NOFS);
145 status = ocfs2_super_lock(osb, 1);
147 @@ -1045,8 +1084,28 @@ restart:
148 * clear it until ocfs2_recover_node() has succeeded. */
149 node_num = rm->rm_entries[0];
150 spin_unlock(&osb->osb_lock);
151 + mlog(0, "checking node %d\n", node_num);
152 + slot_num = ocfs2_node_num_to_slot(osb, node_num);
153 + if (slot_num == -ENOENT) {
155 + mlog(0, "no slot for this node, so no recovery"
157 + goto skip_recovery;
159 + mlog(0, "node %d was using slot %d\n", node_num, slot_num);
161 - status = ocfs2_recover_node(osb, node_num);
162 + /* It is a bit subtle with quota recovery. We cannot do it
163 + * immediately because we have to obtain cluster locks from
164 + * quota files and we also don't want to just skip it because
165 + * then quota usage would be out of sync until some node takes
166 + * the slot. So we remember which nodes need quota recovery
167 + * and when everything else is done, we recover quotas. */
168 + for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++);
169 + if (i == rm_quota_used)
170 + rm_quota[rm_quota_used++] = slot_num;
172 + status = ocfs2_recover_node(osb, node_num, slot_num);
175 ocfs2_recovery_map_clear(osb, node_num);
177 @@ -1070,11 +1129,22 @@ restart:
179 ocfs2_super_unlock(osb, 1);
181 + /* Now it is right time to recover quotas... */
182 + for (i = 0; i < rm_quota_used; i++) {
183 + qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
184 + if (IS_ERR(qrec)) {
185 + status = PTR_ERR(qrec);
186 + mlog_errno(status);
188 + ocfs2_queue_recovery_completion(osb->journal, rm_quota[i],
192 /* We always run recovery on our own orphan dir - the dead
193 * node(s) may have disallowd a previos inode delete. Re-processing
194 * is therefore required. */
195 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL,
200 mutex_lock(&osb->recovery_lock);
201 @@ -1089,6 +1159,9 @@ bail:
203 mutex_unlock(&osb->recovery_lock);
209 /* no one is callint kthread_stop() for us so the kthread() api
210 * requires that we call do_exit(). And it isn't exported, but
211 @@ -1317,31 +1390,19 @@ done:
212 * far less concerning.
214 static int ocfs2_recover_node(struct ocfs2_super *osb,
216 + int node_num, int slot_num)
220 struct ocfs2_dinode *la_copy = NULL;
221 struct ocfs2_dinode *tl_copy = NULL;
223 - mlog_entry("(node_num=%d, osb->node_num = %d)\n",
224 - node_num, osb->node_num);
226 - mlog(0, "checking node %d\n", node_num);
227 + mlog_entry("(node_num=%d, slot_num=%d, osb->node_num = %d)\n",
228 + node_num, slot_num, osb->node_num);
230 /* Should not ever be called to recover ourselves -- in that
231 * case we should've called ocfs2_journal_load instead. */
232 BUG_ON(osb->node_num == node_num);
234 - slot_num = ocfs2_node_num_to_slot(osb, node_num);
235 - if (slot_num == -ENOENT) {
237 - mlog(0, "no slot for this node, so no recovery required.\n");
241 - mlog(0, "node %d was using slot %d\n", node_num, slot_num);
243 status = ocfs2_replay_journal(osb, node_num, slot_num);
245 if (status == -EBUSY) {
246 @@ -1377,7 +1438,7 @@ static int ocfs2_recover_node(struct ocf
248 /* This will kfree the memory pointed to by la_copy and tl_copy */
249 ocfs2_queue_recovery_completion(osb->journal, slot_num, la_copy,
255 --- a/fs/ocfs2/journal.h
256 +++ b/fs/ocfs2/journal.h
257 @@ -173,6 +173,7 @@ void ocfs2_recovery_thread(struct ocfs
259 int ocfs2_mark_dead_nodes(struct ocfs2_super *osb);
260 void ocfs2_complete_mount_recovery(struct ocfs2_super *osb);
261 +void ocfs2_complete_quota_recovery(struct ocfs2_super *osb);
263 static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb)
265 --- a/fs/ocfs2/ocfs2.h
266 +++ b/fs/ocfs2/ocfs2.h
267 @@ -209,6 +209,7 @@ enum ocfs2_mount_options
268 struct ocfs2_journal;
269 struct ocfs2_slot_info;
270 struct ocfs2_recovery_map;
271 +struct ocfs2_quota_recovery;
274 struct task_struct *commit_task;
275 @@ -290,10 +291,11 @@ struct ocfs2_super
276 char *local_alloc_debug_buf;
279 - /* Next two fields are for local node slot recovery during
280 + /* Next three fields are for local node slot recovery during
283 struct ocfs2_dinode *local_alloc_copy;
284 + struct ocfs2_quota_recovery *quota_rec;
286 struct ocfs2_alloc_stats alloc_stats;
287 char dev_str[20]; /* "major,minor" of the device */
288 --- a/fs/ocfs2/quota.h
289 +++ b/fs/ocfs2/quota.h
290 @@ -38,6 +38,17 @@ struct ocfs2_dquot {
291 s64 dq_originodes; /* Last globally synced inode usage */
294 +/* Description of one chunk to recover in memory */
295 +struct ocfs2_recovery_chunk {
296 + struct list_head rc_list; /* List of chunks */
297 + int rc_chunk; /* Chunk number */
298 + unsigned long *rc_bitmap; /* Bitmap of entries to recover */
301 +struct ocfs2_quota_recovery {
302 + struct list_head r_list[MAXQUOTAS]; /* List of chunks to recover */
305 /* In-memory structure with quota header information */
306 struct ocfs2_mem_dqinfo {
307 unsigned int dqi_type; /* Quota type this structure describes */
308 @@ -54,6 +65,10 @@ struct ocfs2_mem_dqinfo {
309 struct buffer_head *dqi_ibh; /* Buffer with information header */
310 struct qtree_mem_dqinfo dqi_gi; /* Info about global file */
311 struct timer_list dqi_sync_timer; /* Timer for syncing dquots */
312 + struct ocfs2_quota_recovery *dqi_rec; /* Pointer to recovery
313 + * information, in case we
314 + * enable quotas on file
318 static inline struct ocfs2_dquot *OCFS2_DQUOT(struct dquot *dquot)
319 @@ -72,6 +87,12 @@ extern struct kmem_cache *ocfs2_qf_chunk
321 extern struct qtree_fmt_operations ocfs2_global_ops;
323 +struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
324 + struct ocfs2_super *osb, int slot_num);
325 +int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
326 + struct ocfs2_quota_recovery *rec,
328 +void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec);
329 ssize_t ocfs2_quota_read(struct super_block *sb, int type, char *data,
330 size_t len, loff_t off);
331 ssize_t ocfs2_quota_write(struct super_block *sb, int type,
332 --- a/fs/ocfs2/quota_local.c
333 +++ b/fs/ocfs2/quota_local.c
334 @@ -49,14 +49,25 @@ static unsigned int ol_quota_chunk_block
335 return 1 + (ol_chunk_blocks(sb) + 1) * c;
338 -/* Offset of the dquot structure in the quota file */
339 -static loff_t ol_dqblk_off(struct super_block *sb, int c, int off)
340 +static unsigned int ol_dqblk_block(struct super_block *sb, int c, int off)
342 + int epb = ol_quota_entries_per_block(sb);
344 + return ol_quota_chunk_block(sb, c) + 1 + off / epb;
347 +static unsigned int ol_dqblk_block_off(struct super_block *sb, int c, int off)
349 int epb = ol_quota_entries_per_block(sb);
351 - return ((ol_quota_chunk_block(sb, c) + 1 + off / epb)
352 - << sb->s_blocksize_bits) +
353 - (off % epb) * sizeof(struct ocfs2_local_disk_dqblk);
354 + return (off % epb) * sizeof(struct ocfs2_local_disk_dqblk);
357 +/* Offset of the dquot structure in the quota file */
358 +static loff_t ol_dqblk_off(struct super_block *sb, int c, int off)
360 + return (ol_dqblk_block(sb, c, off) << sb->s_blocksize_bits) +
361 + ol_dqblk_block_off(sb, c, off);
364 /* Compute block number from given offset */
365 @@ -253,6 +264,382 @@ static void olq_update_info(struct buffe
366 spin_unlock(&dq_data_lock);
369 +static int ocfs2_add_recovery_chunk(struct super_block *sb,
370 + struct ocfs2_local_disk_chunk *dchunk,
372 + struct list_head *head)
374 + struct ocfs2_recovery_chunk *rc;
376 + rc = kmalloc(sizeof(struct ocfs2_recovery_chunk), GFP_NOFS);
379 + rc->rc_chunk = chunk;
380 + rc->rc_bitmap = kmalloc(sb->s_blocksize, GFP_NOFS);
381 + if (!rc->rc_bitmap) {
385 + memcpy(rc->rc_bitmap, dchunk->dqc_bitmap,
386 + (ol_chunk_entries(sb) + 7) >> 3);
387 + list_add_tail(&rc->rc_list, head);
391 +static void free_recovery_list(struct list_head *head)
393 + struct ocfs2_recovery_chunk *next;
394 + struct ocfs2_recovery_chunk *rchunk;
396 + list_for_each_entry_safe(rchunk, next, head, rc_list) {
397 + list_del(&rchunk->rc_list);
398 + kfree(rchunk->rc_bitmap);
403 +void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec)
407 + for (type = 0; type < MAXQUOTAS; type++)
408 + free_recovery_list(&(rec->r_list[type]));
412 +/* Load entries in our quota file we have to recover*/
413 +static int ocfs2_recovery_load_quota(struct inode *lqinode,
414 + struct ocfs2_local_disk_dqinfo *ldinfo,
416 + struct list_head *head)
418 + struct super_block *sb = lqinode->i_sb;
419 + struct buffer_head *hbh;
420 + struct ocfs2_local_disk_chunk *dchunk;
421 + int i, chunks = le32_to_cpu(ldinfo->dqi_chunks);
424 + for (i = 0; i < chunks; i++) {
425 + hbh = ocfs2_bread(lqinode, ol_quota_chunk_block(sb, i),
428 + mlog_errno(status);
431 + dchunk = (struct ocfs2_local_disk_chunk *)hbh->b_data;
432 + if (le32_to_cpu(dchunk->dqc_free) < ol_chunk_entries(sb))
433 + status = ocfs2_add_recovery_chunk(sb, dchunk, i, head);
439 + free_recovery_list(head);
443 +static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void)
446 + struct ocfs2_quota_recovery *rec;
448 + rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS);
451 + for (type = 0; type < MAXQUOTAS; type++)
452 + INIT_LIST_HEAD(&(rec->r_list[type]));
456 +/* Load information we need for quota recovery into memory */
457 +struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
458 + struct ocfs2_super *osb,
461 + unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
462 + OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
463 + unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
464 + LOCAL_GROUP_QUOTA_SYSTEM_INODE };
465 + struct super_block *sb = osb->sb;
466 + struct ocfs2_local_disk_dqinfo *ldinfo;
467 + struct inode *lqinode;
468 + struct buffer_head *bh;
471 + struct ocfs2_quota_recovery *rec;
473 + mlog(ML_NOTICE, "Beginning quota recovery in slot %u\n", slot_num);
474 + rec = ocfs2_alloc_quota_recovery();
476 + return ERR_PTR(-ENOMEM);
477 + /* First init... */
479 + for (type = 0; type < MAXQUOTAS; type++) {
480 + if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
482 + lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num);
487 + status = ocfs2_inode_lock_full(lqinode, NULL, 1,
488 + OCFS2_META_LOCK_NOQUEUE);
489 + /* Someone else is holding the lock? Then he must be
490 + * doing the recovery. Just skip the file... */
491 + if (status == -EAGAIN) {
492 + mlog(ML_NOTICE, "skipping quota recovery for slot %d "
493 + "because quota file is locked.\n", slot_num);
496 + } else if (status < 0) {
497 + mlog_errno(status);
500 + /* Now read local header */
501 + bh = ocfs2_bread(lqinode, 0, &status, 0);
503 + mlog_errno(status);
504 + mlog(ML_ERROR, "failed to read quota file info header "
505 + "(slot=%d type=%d)\n", slot_num, type);
508 + ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
509 + OCFS2_LOCAL_INFO_OFF);
510 + status = ocfs2_recovery_load_quota(lqinode, ldinfo, type,
511 + &rec->r_list[type]);
514 + ocfs2_inode_unlock(lqinode, 1);
522 + ocfs2_free_quota_recovery(rec);
523 + rec = ERR_PTR(status);
528 +/* Sync changes in local quota file into global quota file and
529 + * reinitialize local quota file.
530 + * The function expects local quota file to be already locked and
531 + * dqonoff_mutex locked. */
532 +static int ocfs2_recover_local_quota_file(struct inode *lqinode,
534 + struct ocfs2_quota_recovery *rec)
536 + struct super_block *sb = lqinode->i_sb;
537 + struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
538 + struct ocfs2_local_disk_chunk *dchunk;
539 + struct ocfs2_local_disk_dqblk *dqblk;
540 + struct dquot *dquot;
542 + struct buffer_head *hbh = NULL, *qbh = NULL;
545 + struct ocfs2_recovery_chunk *rchunk, *next;
546 + qsize_t spacechange, inodechange;
548 + mlog_entry("ino=%lu type=%u", (unsigned long)lqinode->i_ino, type);
550 + status = ocfs2_lock_global_qf(oinfo, 1);
554 + list_for_each_entry_safe(rchunk, next, &(rec->r_list[type]), rc_list) {
555 + chunk = rchunk->rc_chunk;
556 + hbh = ocfs2_bread(lqinode, ol_quota_chunk_block(sb, chunk),
559 + mlog_errno(status);
562 + dchunk = (struct ocfs2_local_disk_chunk *)hbh->b_data;
563 + for_each_bit(bit, rchunk->rc_bitmap, ol_chunk_entries(sb)) {
564 + qbh = ocfs2_bread(lqinode,
565 + ol_dqblk_block(sb, chunk, bit),
568 + mlog_errno(status);
571 + dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
572 + ol_dqblk_block_off(sb, chunk, bit));
573 + dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type);
576 + mlog(ML_ERROR, "Failed to get quota structure "
577 + "for id %u, type %d. Cannot finish quota "
578 + "file recovery.\n",
579 + (unsigned)le64_to_cpu(dqblk->dqb_id),
583 + handle = ocfs2_start_trans(OCFS2_SB(sb),
584 + OCFS2_QSYNC_CREDITS);
585 + if (IS_ERR(handle)) {
586 + status = PTR_ERR(handle);
587 + mlog_errno(status);
588 + goto out_put_dquot;
590 + mutex_lock(&sb_dqopt(sb)->dqio_mutex);
591 + spin_lock(&dq_data_lock);
592 + /* Add usage from quota entry into quota changes
593 + * of our node. Auxiliary variables are important
594 + * due to signedness */
595 + spacechange = le64_to_cpu(dqblk->dqb_spacemod);
596 + inodechange = le64_to_cpu(dqblk->dqb_inodemod);
597 + dquot->dq_dqb.dqb_curspace += spacechange;
598 + dquot->dq_dqb.dqb_curinodes += inodechange;
599 + spin_unlock(&dq_data_lock);
600 + /* We want to drop reference held by the crashed
601 + * node. Since we have our own reference we know
602 + * global structure actually won't be freed. */
603 + status = ocfs2_global_release_dquot(dquot);
605 + mlog_errno(status);
608 + /* Release local quota file entry */
609 + status = ocfs2_journal_access(handle, lqinode,
610 + qbh, OCFS2_JOURNAL_ACCESS_WRITE);
612 + mlog_errno(status);
616 + WARN_ON(!ocfs2_test_bit(bit, dchunk->dqc_bitmap));
617 + ocfs2_clear_bit(bit, dchunk->dqc_bitmap);
618 + le32_add_cpu(&dchunk->dqc_free, 1);
619 + unlock_buffer(qbh);
620 + status = ocfs2_journal_dirty(handle, qbh);
622 + mlog_errno(status);
624 + mutex_unlock(&sb_dqopt(sb)->dqio_mutex);
625 + ocfs2_commit_trans(OCFS2_SB(sb), handle);
634 + list_del(&rchunk->rc_list);
635 + kfree(rchunk->rc_bitmap);
640 + ocfs2_unlock_global_qf(oinfo, 1);
643 + free_recovery_list(&(rec->r_list[type]));
648 +/* Recover local quota files for given node different from us */
649 +int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
650 + struct ocfs2_quota_recovery *rec,
653 + unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
654 + LOCAL_GROUP_QUOTA_SYSTEM_INODE };
655 + struct super_block *sb = osb->sb;
656 + struct ocfs2_local_disk_dqinfo *ldinfo;
657 + struct buffer_head *bh;
661 + struct inode *lqinode;
662 + unsigned int flags;
664 + mlog(ML_NOTICE, "Finishing quota recovery in slot %u\n", slot_num);
665 + mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
666 + for (type = 0; type < MAXQUOTAS; type++) {
667 + if (list_empty(&(rec->r_list[type])))
669 + mlog(0, "Recovering quota in slot %d\n", slot_num);
670 + lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num);
675 + status = ocfs2_inode_lock_full(lqinode, NULL, 1,
676 + OCFS2_META_LOCK_NOQUEUE);
677 + /* Someone else is holding the lock? Then he must be
678 + * doing the recovery. Just skip the file... */
679 + if (status == -EAGAIN) {
680 + mlog(ML_NOTICE, "skipping quota recovery for slot %d "
681 + "because quota file is locked.\n", slot_num);
684 + } else if (status < 0) {
685 + mlog_errno(status);
688 + /* Now read local header */
689 + bh = ocfs2_bread(lqinode, 0, &status, 0);
691 + mlog_errno(status);
692 + mlog(ML_ERROR, "failed to read quota file info header "
693 + "(slot=%d type=%d)\n", slot_num, type);
696 + ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
697 + OCFS2_LOCAL_INFO_OFF);
698 + /* Is recovery still needed? */
699 + flags = le32_to_cpu(ldinfo->dqi_flags);
700 + if (!(flags & OLQF_CLEAN))
701 + status = ocfs2_recover_local_quota_file(lqinode,
704 + /* We don't want to mark file as clean when it is actually
706 + if (slot_num == osb->slot_num)
708 + /* Mark quota file as clean if we are recovering quota file of
709 + * some other node. */
710 + handle = ocfs2_start_trans(osb, 1);
711 + if (IS_ERR(handle)) {
712 + status = PTR_ERR(handle);
713 + mlog_errno(status);
716 + status = ocfs2_journal_access(handle, lqinode, bh,
717 + OCFS2_JOURNAL_ACCESS_WRITE);
719 + mlog_errno(status);
723 + ldinfo->dqi_flags = cpu_to_le32(flags | OLQF_CLEAN);
725 + status = ocfs2_journal_dirty(handle, bh);
727 + mlog_errno(status);
729 + ocfs2_commit_trans(osb, handle);
733 + ocfs2_inode_unlock(lqinode, 1);
740 + mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
745 /* Read information header from quota file */
746 static int ocfs2_local_read_info(struct super_block *sb, int type)
748 @@ -262,6 +649,7 @@ static int ocfs2_local_read_info(struct
749 struct inode *lqinode = sb_dqopt(sb)->files[type];
751 struct buffer_head *bh = NULL;
752 + struct ocfs2_quota_recovery *rec;
755 info->dqi_maxblimit = 0x7fffffffffffffffLL;
756 @@ -275,6 +663,7 @@ static int ocfs2_local_read_info(struct
757 info->dqi_priv = oinfo;
758 oinfo->dqi_type = type;
759 INIT_LIST_HEAD(&oinfo->dqi_chunk);
760 + oinfo->dqi_rec = NULL;
761 oinfo->dqi_lqi_bh = NULL;
762 oinfo->dqi_ibh = NULL;
764 @@ -305,10 +694,27 @@ static int ocfs2_local_read_info(struct
767 /* We crashed when using local quota file? */
768 - if (!(info->dqi_flags & OLQF_CLEAN))
769 - goto out_err; /* So far we just bail out. Later we should resync here */
770 + if (!(info->dqi_flags & OLQF_CLEAN)) {
771 + rec = OCFS2_SB(sb)->quota_rec;
773 + rec = ocfs2_alloc_quota_recovery();
776 + mlog_errno(status);
779 + OCFS2_SB(sb)->quota_rec = rec;
782 - status = ocfs2_load_local_quota_bitmaps(sb_dqopt(sb)->files[type],
783 + status = ocfs2_recovery_load_quota(lqinode, ldinfo, type,
784 + &rec->r_list[type]);
786 + mlog_errno(status);
791 + status = ocfs2_load_local_quota_bitmaps(lqinode,
795 @@ -394,6 +800,12 @@ static int ocfs2_local_free_info(struct
797 ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
799 + /* dqonoff_mutex protects us against racing with recovery thread... */
800 + if (oinfo->dqi_rec) {
801 + ocfs2_free_quota_recovery(oinfo->dqi_rec);
808 --- a/fs/ocfs2/super.c
809 +++ b/fs/ocfs2/super.c
810 @@ -973,6 +973,9 @@ static int ocfs2_fill_super(struct super
811 goto read_super_error;
815 + ocfs2_complete_quota_recovery(osb);
817 /* Now we wake up again for processes waiting for quotas */
818 atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS);
819 wake_up(&osb->osb_mount_event);