Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gfs2-v6.4-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull gfs2 updates from Andreas Gruenbacher:

- Move the freeze/thaw logic from glock callback context to process /
worker thread context to prevent deadlocks

- Fix a quota reference couting bug in do_qc()

- Carry on deallocating inodes even when gfs2_rindex_update() fails

- Retry filesystem-internal reads when they are interruped by a signal

- Eliminate kmap_atomic() in favor of kmap_local_page() /
memcpy_{from,to}_page()

- Get rid of noop_direct_IO

- And a few more minor fixes and cleanups

* tag 'gfs2-v6.4-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: (23 commits)
gfs2: Add quota_change type
gfs2: Use memcpy_{from,to}_page where appropriate
gfs2: Convert remaining kmap_atomic calls to kmap_local_page
gfs2: Replace deprecated kmap_atomic with kmap_local_page
gfs: Get rid of unnucessary locking in inode_go_dump
gfs2: gfs2_freeze_lock_shared cleanup
gfs2: Replace sd_freeze_state with SDF_FROZEN flag
gfs2: Rework freeze / thaw logic
gfs2: Rename SDF_{FS_FROZEN => FREEZE_INITIATOR}
gfs2: Reconfiguring frozen filesystem already rejected
gfs2: Rename gfs2_freeze_lock{ => _shared }
gfs2: Rename the {freeze,thaw}_super callbacks
gfs2: Rename remaining "transaction" glock references
gfs2: retry interrupted internal reads
gfs2: Fix possible data races in gfs2_show_options()
gfs2: Fix duplicate should_fault_in_pages() call
gfs2: set FMODE_CAN_ODIRECT instead of a dummy direct_IO method
gfs2: Don't remember delete unless it's successful
gfs2: Update rl_unlinked before releasing rgrp lock
gfs2: Fix gfs2_qa_get imbalance in gfs2_quota_hold
...

+276 -236
+9 -10
fs/gfs2/aops.c
··· 432 432 if (error) 433 433 return error; 434 434 435 - kaddr = kmap_atomic(page); 435 + kaddr = kmap_local_page(page); 436 436 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); 437 437 memset(kaddr + dsize, 0, PAGE_SIZE - dsize); 438 - kunmap_atomic(kaddr); 438 + kunmap_local(kaddr); 439 439 flush_dcache_page(page); 440 440 brelse(dibh); 441 441 SetPageUptodate(page); ··· 489 489 unsigned copied = 0; 490 490 unsigned amt; 491 491 struct page *page; 492 - void *p; 493 492 494 493 do { 494 + page = read_cache_page(mapping, index, gfs2_read_folio, NULL); 495 + if (IS_ERR(page)) { 496 + if (PTR_ERR(page) == -EINTR) 497 + continue; 498 + return PTR_ERR(page); 499 + } 495 500 amt = size - copied; 496 501 if (offset + size > PAGE_SIZE) 497 502 amt = PAGE_SIZE - offset; 498 - page = read_cache_page(mapping, index, gfs2_read_folio, NULL); 499 - if (IS_ERR(page)) 500 - return PTR_ERR(page); 501 - p = kmap_atomic(page); 502 - memcpy(buf + copied, p + offset, amt); 503 - kunmap_atomic(p); 503 + memcpy_from_page(buf + copied, page, offset, amt); 504 504 put_page(page); 505 505 copied += amt; 506 506 index++; ··· 751 751 .release_folio = iomap_release_folio, 752 752 .invalidate_folio = iomap_invalidate_folio, 753 753 .bmap = gfs2_bmap, 754 - .direct_IO = noop_direct_IO, 755 754 .migrate_folio = filemap_migrate_folio, 756 755 .is_partially_uptodate = iomap_is_partially_uptodate, 757 756 .error_remove_page = generic_error_remove_page,
+2 -2
fs/gfs2/bmap.c
··· 1729 1729 1730 1730 if (offset >= maxsize) { 1731 1731 /* 1732 - * The starting point lies beyond the allocated meta-data; 1733 - * there are no blocks do deallocate. 1732 + * The starting point lies beyond the allocated metadata; 1733 + * there are no blocks to deallocate. 1734 1734 */ 1735 1735 return 0; 1736 1736 }
+4 -1
fs/gfs2/file.c
··· 630 630 ret = generic_file_open(inode, file); 631 631 if (ret) 632 632 return ret; 633 + 634 + if (!gfs2_is_jdata(GFS2_I(inode))) 635 + file->f_mode |= FMODE_CAN_ODIRECT; 633 636 } 634 637 635 638 fp = kzalloc(sizeof(struct gfs2_file), GFP_NOFS); ··· 1033 1030 } 1034 1031 1035 1032 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, gh); 1036 - retry: 1037 1033 if (should_fault_in_pages(from, iocb, &prev_count, &window_size)) { 1034 + retry: 1038 1035 window_size -= fault_in_iov_iter_readable(from, window_size); 1039 1036 if (!window_size) { 1040 1037 ret = -EFAULT;
+2 -2
fs/gfs2/glock.c
··· 145 145 * 146 146 * We need to allow some glocks to be enqueued, dequeued, promoted, and demoted 147 147 * when we're withdrawn. For example, to maintain metadata integrity, we should 148 - * disallow the use of inode and rgrp glocks when withdrawn. Other glocks, like 149 - * iopen or the transaction glocks may be safely used because none of their 148 + * disallow the use of inode and rgrp glocks when withdrawn. Other glocks like 149 + * the iopen or freeze glock may be safely used because none of their 150 150 * metadata goes through the journal. So in general, we should disallow all 151 151 * glocks that are journaled, and allow all the others. One exception is: 152 152 * we need to allow our active journal to be promoted and demoted so others
+25 -44
fs/gfs2/glops.c
··· 236 236 truncate_inode_pages_range(mapping, start, end); 237 237 } 238 238 239 - static void gfs2_rgrp_go_dump(struct seq_file *seq, struct gfs2_glock *gl, 239 + static void gfs2_rgrp_go_dump(struct seq_file *seq, const struct gfs2_glock *gl, 240 240 const char *fs_id_buf) 241 241 { 242 242 struct gfs2_rgrpd *rgd = gl->gl_object; ··· 536 536 * 537 537 */ 538 538 539 - static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl, 539 + static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl, 540 540 const char *fs_id_buf) 541 541 { 542 542 struct gfs2_inode *ip = gl->gl_object; 543 - struct inode *inode; 544 - unsigned long nrpages; 543 + const struct inode *inode = &ip->i_inode; 545 544 546 545 if (ip == NULL) 547 546 return; 548 - 549 - inode = &ip->i_inode; 550 - xa_lock_irq(&inode->i_data.i_pages); 551 - nrpages = inode->i_data.nrpages; 552 - xa_unlock_irq(&inode->i_data.i_pages); 553 547 554 548 gfs2_print_dbg(seq, "%s I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu " 555 549 "p:%lu\n", fs_id_buf, 556 550 (unsigned long long)ip->i_no_formal_ino, 557 551 (unsigned long long)ip->i_no_addr, 558 - IF2DT(ip->i_inode.i_mode), ip->i_flags, 552 + IF2DT(inode->i_mode), ip->i_flags, 559 553 (unsigned int)ip->i_diskflags, 560 - (unsigned long long)i_size_read(inode), nrpages); 554 + (unsigned long long)i_size_read(inode), 555 + inode->i_data.nrpages); 561 556 } 562 557 563 558 /** 564 - * freeze_go_sync - promote/demote the freeze glock 559 + * freeze_go_callback - A cluster node is requesting a freeze 565 560 * @gl: the glock 561 + * @remote: true if this came from a different cluster node 566 562 */ 567 563 568 - static int freeze_go_sync(struct gfs2_glock *gl) 564 + static void freeze_go_callback(struct gfs2_glock *gl, bool remote) 569 565 { 570 - int error = 0; 571 566 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 567 + struct super_block *sb = sdp->sd_vfs; 568 + 569 + if (!remote || 570 + gl->gl_state != LM_ST_SHARED || 571 + gl->gl_demote_state != LM_ST_UNLOCKED) 572 + return; 572 573 573 574 /* 574 - * We need to check gl_state == LM_ST_SHARED here and not gl_req == 575 - * LM_ST_EXCLUSIVE. That's because when any node does a freeze, 576 - * all the nodes should have the freeze glock in SH mode and they all 577 - * call do_xmote: One for EX and the others for UN. They ALL must 578 - * freeze locally, and they ALL must queue freeze work. The freeze_work 579 - * calls freeze_func, which tries to reacquire the freeze glock in SH, 580 - * effectively waiting for the thaw on the node who holds it in EX. 581 - * Once thawed, the work func acquires the freeze glock in 582 - * SH and everybody goes back to thawed. 575 + * Try to get an active super block reference to prevent racing with 576 + * unmount (see trylock_super()). But note that unmount isn't the only 577 + * place where a write lock on s_umount is taken, and we can fail here 578 + * because of things like remount as well. 583 579 */ 584 - if (gl->gl_state == LM_ST_SHARED && !gfs2_withdrawn(sdp) && 585 - !test_bit(SDF_NORECOVERY, &sdp->sd_flags)) { 586 - atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE); 587 - error = freeze_super(sdp->sd_vfs); 588 - if (error) { 589 - fs_info(sdp, "GFS2: couldn't freeze filesystem: %d\n", 590 - error); 591 - if (gfs2_withdrawn(sdp)) { 592 - atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); 593 - return 0; 594 - } 595 - gfs2_assert_withdraw(sdp, 0); 596 - } 597 - queue_work(gfs2_freeze_wq, &sdp->sd_freeze_work); 598 - if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) 599 - gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE | 600 - GFS2_LFC_FREEZE_GO_SYNC); 601 - else /* read-only mounts */ 602 - atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); 580 + if (down_read_trylock(&sb->s_umount)) { 581 + atomic_inc(&sb->s_active); 582 + up_read(&sb->s_umount); 583 + if (!queue_work(gfs2_freeze_wq, &sdp->sd_freeze_work)) 584 + deactivate_super(sb); 603 585 } 604 - return 0; 605 586 } 606 587 607 588 /** ··· 742 761 }; 743 762 744 763 const struct gfs2_glock_operations gfs2_freeze_glops = { 745 - .go_sync = freeze_go_sync, 746 764 .go_xmote_bh = freeze_go_xmote_bh, 747 765 .go_demote_ok = freeze_go_demote_ok, 766 + .go_callback = freeze_go_callback, 748 767 .go_type = LM_TYPE_NONDISK, 749 768 .go_flags = GLOF_NONDISK, 750 769 };
+3 -9
fs/gfs2/incore.h
··· 221 221 int (*go_demote_ok) (const struct gfs2_glock *gl); 222 222 int (*go_instantiate) (struct gfs2_glock *gl); 223 223 int (*go_held)(struct gfs2_holder *gh); 224 - void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl, 224 + void (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl, 225 225 const char *fs_id_buf); 226 226 void (*go_callback)(struct gfs2_glock *gl, bool remote); 227 227 void (*go_free)(struct gfs2_glock *gl); ··· 600 600 SDF_RORECOVERY = 7, /* read only recovery */ 601 601 SDF_SKIP_DLM_UNLOCK = 8, 602 602 SDF_FORCE_AIL_FLUSH = 9, 603 - SDF_FS_FROZEN = 10, 603 + SDF_FREEZE_INITIATOR = 10, 604 604 SDF_WITHDRAWING = 11, /* Will withdraw eventually */ 605 605 SDF_WITHDRAW_IN_PROG = 12, /* Withdraw is in progress */ 606 606 SDF_REMOTE_WITHDRAW = 13, /* Performing remote recovery */ ··· 608 608 withdrawing */ 609 609 SDF_DEACTIVATING = 15, 610 610 SDF_EVICTING = 16, 611 - }; 612 - 613 - enum gfs2_freeze_state { 614 - SFS_UNFROZEN = 0, 615 - SFS_STARTING_FREEZE = 1, 616 - SFS_FROZEN = 2, 611 + SDF_FROZEN = 17, 617 612 }; 618 613 619 614 #define GFS2_FSNAME_LEN 256 ··· 836 841 837 842 /* For quiescing the filesystem */ 838 843 struct gfs2_holder sd_freeze_gh; 839 - atomic_t sd_freeze_state; 840 844 struct mutex sd_freeze_mutex; 841 845 842 846 char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
+10 -13
fs/gfs2/lock_dlm.c
··· 296 296 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 297 297 int error; 298 298 299 - if (gl->gl_lksb.sb_lkid == 0) { 300 - gfs2_glock_free(gl); 301 - return; 302 - } 299 + if (gl->gl_lksb.sb_lkid == 0) 300 + goto out_free; 303 301 304 302 clear_bit(GLF_BLOCKING, &gl->gl_flags); 305 303 gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); ··· 305 307 gfs2_update_request_times(gl); 306 308 307 309 /* don't want to call dlm if we've unmounted the lock protocol */ 308 - if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) { 309 - gfs2_glock_free(gl); 310 - return; 311 - } 310 + if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) 311 + goto out_free; 312 312 /* don't want to skip dlm_unlock writing the lvb when lock has one */ 313 313 314 314 if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) && 315 - !gl->gl_lksb.sb_lvbptr) { 316 - gfs2_glock_free(gl); 317 - return; 318 - } 315 + !gl->gl_lksb.sb_lvbptr) 316 + goto out_free; 319 317 320 318 again: 321 319 error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK, ··· 325 331 fs_err(sdp, "gdlm_unlock %x,%llx err=%d\n", 326 332 gl->gl_name.ln_type, 327 333 (unsigned long long)gl->gl_name.ln_number, error); 328 - return; 329 334 } 335 + return; 336 + 337 + out_free: 338 + gfs2_glock_free(gl); 330 339 } 331 340 332 341 static void gdlm_cancel(struct gfs2_glock *gl)
+4 -7
fs/gfs2/log.c
··· 914 914 static void log_write_header(struct gfs2_sbd *sdp, u32 flags) 915 915 { 916 916 blk_opf_t op_flags = REQ_PREFLUSH | REQ_FUA | REQ_META | REQ_SYNC; 917 - enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); 918 917 919 - gfs2_assert_withdraw(sdp, (state != SFS_FROZEN)); 918 + gfs2_assert_withdraw(sdp, !test_bit(SDF_FROZEN, &sdp->sd_flags)); 920 919 921 920 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) { 922 921 gfs2_ordered_wait(sdp); ··· 1035 1036 { 1036 1037 struct gfs2_trans *tr = NULL; 1037 1038 unsigned int reserved_blocks = 0, used_blocks = 0; 1038 - enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); 1039 + bool frozen = test_bit(SDF_FROZEN, &sdp->sd_flags); 1039 1040 unsigned int first_log_head; 1040 1041 unsigned int reserved_revokes = 0; 1041 1042 ··· 1066 1067 if (tr) { 1067 1068 sdp->sd_log_tr = NULL; 1068 1069 tr->tr_first = first_log_head; 1069 - if (unlikely (state == SFS_FROZEN)) { 1070 + if (unlikely(frozen)) { 1070 1071 if (gfs2_assert_withdraw_delayed(sdp, 1071 1072 !tr->tr_num_buf_new && !tr->tr_num_databuf_new)) 1072 1073 goto out_withdraw; ··· 1091 1092 if (flags & GFS2_LOG_HEAD_FLUSH_SHUTDOWN) 1092 1093 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 1093 1094 1094 - if (unlikely(state == SFS_FROZEN)) 1095 + if (unlikely(frozen)) 1095 1096 if (gfs2_assert_withdraw_delayed(sdp, !reserved_revokes)) 1096 1097 goto out_withdraw; 1097 1098 ··· 1135 1136 if (flags & (GFS2_LOG_HEAD_FLUSH_SHUTDOWN | 1136 1137 GFS2_LOG_HEAD_FLUSH_FREEZE)) 1137 1138 gfs2_log_shutdown(sdp); 1138 - if (flags & GFS2_LOG_HEAD_FLUSH_FREEZE) 1139 - atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); 1140 1139 } 1141 1140 1142 1141 out_end:
+10 -11
fs/gfs2/lops.c
··· 427 427 { 428 428 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 429 429 struct gfs2_log_header_host lh; 430 - void *kaddr = kmap_atomic(page); 430 + void *kaddr; 431 431 unsigned int offset; 432 432 bool ret = false; 433 433 434 + kaddr = kmap_local_page(page); 434 435 for (offset = 0; offset < PAGE_SIZE; offset += sdp->sd_sb.sb_bsize) { 435 436 if (!__get_log_header(sdp, kaddr + offset, 0, &lh)) { 436 437 if (lh.lh_sequence >= head->lh_sequence) ··· 442 441 } 443 442 } 444 443 } 445 - kunmap_atomic(kaddr); 444 + kunmap_local(kaddr); 446 445 return ret; 447 446 } 448 447 ··· 627 626 __be32 *ptr; 628 627 629 628 clear_buffer_escaped(bh); 630 - kaddr = kmap_atomic(bh->b_page); 629 + kaddr = kmap_local_page(bh->b_page); 631 630 ptr = kaddr + bh_offset(bh); 632 631 if (*ptr == cpu_to_be32(GFS2_MAGIC)) 633 632 set_buffer_escaped(bh); 634 - kunmap_atomic(kaddr); 633 + kunmap_local(kaddr); 635 634 } 636 635 637 636 static int blocknr_cmp(void *priv, const struct list_head *a, ··· 697 696 lock_buffer(bd2->bd_bh); 698 697 699 698 if (buffer_escaped(bd2->bd_bh)) { 700 - void *kaddr; 699 + void *p; 700 + 701 701 page = mempool_alloc(gfs2_page_pool, GFP_NOIO); 702 - ptr = page_address(page); 703 - kaddr = kmap_atomic(bd2->bd_bh->b_page); 704 - memcpy(ptr, kaddr + bh_offset(bd2->bd_bh), 705 - bd2->bd_bh->b_size); 706 - kunmap_atomic(kaddr); 707 - *(__be32 *)ptr = 0; 702 + p = page_address(page); 703 + memcpy_from_page(p, page, bh_offset(bd2->bd_bh), bd2->bd_bh->b_size); 704 + *(__be32 *)p = 0; 708 705 clear_buffer_escaped(bd2->bd_bh); 709 706 unlock_buffer(bd2->bd_bh); 710 707 brelse(bd2->bd_bh);
+3 -12
fs/gfs2/ops_fstype.c
··· 135 135 init_rwsem(&sdp->sd_log_flush_lock); 136 136 atomic_set(&sdp->sd_log_in_flight, 0); 137 137 init_waitqueue_head(&sdp->sd_log_flush_wait); 138 - atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); 139 138 mutex_init(&sdp->sd_freeze_mutex); 140 139 141 140 return sdp; ··· 433 434 error = gfs2_glock_get(sdp, GFS2_FREEZE_LOCK, &gfs2_freeze_glops, 434 435 CREATE, &sdp->sd_freeze_gl); 435 436 if (error) { 436 - fs_err(sdp, "can't create transaction glock: %d\n", error); 437 + fs_err(sdp, "can't create freeze glock: %d\n", error); 437 438 goto fail_rename; 438 439 } 439 440 ··· 1139 1140 int silent = fc->sb_flags & SB_SILENT; 1140 1141 struct gfs2_sbd *sdp; 1141 1142 struct gfs2_holder mount_gh; 1142 - struct gfs2_holder freeze_gh; 1143 1143 int error; 1144 1144 1145 1145 sdp = init_sbd(sb); ··· 1267 1269 } 1268 1270 } 1269 1271 1270 - error = gfs2_freeze_lock(sdp, &freeze_gh, 0); 1272 + error = gfs2_freeze_lock_shared(sdp); 1271 1273 if (error) 1272 1274 goto fail_per_node; 1273 1275 1274 1276 if (!sb_rdonly(sb)) 1275 1277 error = gfs2_make_fs_rw(sdp); 1276 1278 1277 - gfs2_freeze_unlock(&freeze_gh); 1278 1279 if (error) { 1280 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 1279 1281 if (sdp->sd_quotad_process) 1280 1282 kthread_stop(sdp->sd_quotad_process); 1281 1283 sdp->sd_quotad_process = NULL; ··· 1588 1590 fc->sb_flags |= SB_RDONLY; 1589 1591 1590 1592 if ((sb->s_flags ^ fc->sb_flags) & SB_RDONLY) { 1591 - struct gfs2_holder freeze_gh; 1592 - 1593 - error = gfs2_freeze_lock(sdp, &freeze_gh, 0); 1594 - if (error) 1595 - return -EINVAL; 1596 - 1597 1593 if (fc->sb_flags & SB_RDONLY) { 1598 1594 gfs2_make_fs_ro(sdp); 1599 1595 } else { ··· 1595 1603 if (error) 1596 1604 errorfc(fc, "unable to remount read-write"); 1597 1605 } 1598 - gfs2_freeze_unlock(&freeze_gh); 1599 1606 } 1600 1607 sdp->sd_args = *newargs; 1601 1608
+14 -12
fs/gfs2/quota.c
··· 75 75 #define GFS2_QD_HASH_SIZE BIT(GFS2_QD_HASH_SHIFT) 76 76 #define GFS2_QD_HASH_MASK (GFS2_QD_HASH_SIZE - 1) 77 77 78 + #define QC_CHANGE 0 79 + #define QC_SYNC 1 80 + 78 81 /* Lock order: qd_lock -> bucket lock -> qd->lockref.lock -> lru lock */ 79 82 /* -> sd_bitmap_lock */ 80 83 static DEFINE_SPINLOCK(qd_lock); ··· 473 470 spin_unlock(&qd_lock); 474 471 475 472 if (qd) { 476 - gfs2_assert_warn(sdp, qd->qd_change_sync); 477 473 error = bh_get(qd); 478 474 if (error) { 479 475 clear_bit(QDF_LOCKED, &qd->qd_flags); ··· 593 591 if (gfs2_assert_warn(sdp, !ip->i_qadata->qa_qd_num) || 594 592 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) { 595 593 error = -EIO; 594 + gfs2_qa_put(ip); 596 595 goto out; 597 596 } 598 597 ··· 664 661 return 0; 665 662 } 666 663 667 - static void do_qc(struct gfs2_quota_data *qd, s64 change) 664 + static void do_qc(struct gfs2_quota_data *qd, s64 change, int qc_type) 668 665 { 669 666 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; 670 667 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); ··· 689 686 qd->qd_change = x; 690 687 spin_unlock(&qd_lock); 691 688 692 - if (!x) { 689 + if (qc_type == QC_CHANGE) { 690 + if (!test_and_set_bit(QDF_CHANGE, &qd->qd_flags)) { 691 + qd_hold(qd); 692 + slot_hold(qd); 693 + } 694 + } else { 693 695 gfs2_assert_warn(sdp, test_bit(QDF_CHANGE, &qd->qd_flags)); 694 696 clear_bit(QDF_CHANGE, &qd->qd_flags); 695 697 qc->qc_flags = 0; 696 698 qc->qc_id = 0; 697 699 slot_put(qd); 698 700 qd_put(qd); 699 - } else if (!test_and_set_bit(QDF_CHANGE, &qd->qd_flags)) { 700 - qd_hold(qd); 701 - slot_hold(qd); 702 701 } 703 702 704 703 if (change < 0) /* Reset quiet flag if we freed some blocks */ ··· 716 711 struct address_space *mapping = inode->i_mapping; 717 712 struct page *page; 718 713 struct buffer_head *bh; 719 - void *kaddr; 720 714 u64 blk; 721 715 unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0; 722 716 unsigned to_write = bytes, pg_off = off; ··· 767 763 } 768 764 769 765 /* Write to the page, now that we have setup the buffer(s) */ 770 - kaddr = kmap_atomic(page); 771 - memcpy(kaddr + off, buf, bytes); 766 + memcpy_to_page(page, off, buf, bytes); 772 767 flush_dcache_page(page); 773 - kunmap_atomic(kaddr); 774 768 unlock_page(page); 775 769 put_page(page); 776 770 ··· 957 955 if (error) 958 956 goto out_end_trans; 959 957 960 - do_qc(qd, -qd->qd_change_sync); 958 + do_qc(qd, -qd->qd_change_sync, QC_SYNC); 961 959 set_bit(QDF_REFRESH, &qd->qd_flags); 962 960 } 963 961 ··· 1283 1281 1284 1282 if (qid_eq(qd->qd_id, make_kqid_uid(uid)) || 1285 1283 qid_eq(qd->qd_id, make_kqid_gid(gid))) { 1286 - do_qc(qd, change); 1284 + do_qc(qd, change, QC_CHANGE); 1287 1285 } 1288 1286 } 1289 1287 }
+14 -14
fs/gfs2/recovery.c
··· 404 404 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 405 405 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 406 406 struct gfs2_log_header_host head; 407 - struct gfs2_holder j_gh, ji_gh, thaw_gh; 407 + struct gfs2_holder j_gh, ji_gh; 408 408 ktime_t t_start, t_jlck, t_jhd, t_tlck, t_rep; 409 409 int ro = 0; 410 410 unsigned int pass; ··· 420 420 if (sdp->sd_args.ar_spectator) 421 421 goto fail; 422 422 if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) { 423 - fs_info(sdp, "jid=%u: Trying to acquire journal lock...\n", 423 + fs_info(sdp, "jid=%u: Trying to acquire journal glock...\n", 424 424 jd->jd_jid); 425 425 jlocked = 1; 426 - /* Acquire the journal lock so we can do recovery */ 426 + /* Acquire the journal glock so we can do recovery */ 427 427 428 428 error = gfs2_glock_nq_num(sdp, jd->jd_jid, &gfs2_journal_glops, 429 429 LM_ST_EXCLUSIVE, ··· 465 465 ktime_ms_delta(t_jhd, t_jlck)); 466 466 467 467 if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) { 468 - fs_info(sdp, "jid=%u: Acquiring the transaction lock...\n", 469 - jd->jd_jid); 468 + mutex_lock(&sdp->sd_freeze_mutex); 470 469 471 - /* Acquire a shared hold on the freeze lock */ 472 - 473 - error = gfs2_freeze_lock(sdp, &thaw_gh, LM_FLAG_PRIORITY); 474 - if (error) 470 + if (test_bit(SDF_FROZEN, &sdp->sd_flags)) { 471 + mutex_unlock(&sdp->sd_freeze_mutex); 472 + fs_warn(sdp, "jid=%u: Can't replay: filesystem " 473 + "is frozen\n", jd->jd_jid); 475 474 goto fail_gunlock_ji; 475 + } 476 476 477 477 if (test_bit(SDF_RORECOVERY, &sdp->sd_flags)) { 478 478 ro = 1; ··· 496 496 fs_warn(sdp, "jid=%u: Can't replay: read-only block " 497 497 "device\n", jd->jd_jid); 498 498 error = -EROFS; 499 - goto fail_gunlock_thaw; 499 + goto fail_gunlock_nofreeze; 500 500 } 501 501 502 502 t_tlck = ktime_get(); ··· 514 514 lops_after_scan(jd, error, pass); 515 515 if (error) { 516 516 up_read(&sdp->sd_log_flush_lock); 517 - goto fail_gunlock_thaw; 517 + goto fail_gunlock_nofreeze; 518 518 } 519 519 } 520 520 ··· 522 522 clean_journal(jd, &head); 523 523 up_read(&sdp->sd_log_flush_lock); 524 524 525 - gfs2_freeze_unlock(&thaw_gh); 525 + mutex_unlock(&sdp->sd_freeze_mutex); 526 526 t_rep = ktime_get(); 527 527 fs_info(sdp, "jid=%u: Journal replayed in %lldms [jlck:%lldms, " 528 528 "jhead:%lldms, tlck:%lldms, replay:%lldms]\n", ··· 543 543 fs_info(sdp, "jid=%u: Done\n", jd->jd_jid); 544 544 goto done; 545 545 546 - fail_gunlock_thaw: 547 - gfs2_freeze_unlock(&thaw_gh); 546 + fail_gunlock_nofreeze: 547 + mutex_unlock(&sdp->sd_freeze_mutex); 548 548 fail_gunlock_ji: 549 549 if (jlocked) { 550 550 gfs2_glock_dq_uninit(&ji_gh);
+1 -1
fs/gfs2/rgrp.c
··· 2584 2584 2585 2585 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh); 2586 2586 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 2587 - rgrp_unlock_local(rgd); 2588 2587 be32_add_cpu(&rgd->rd_rgl->rl_unlinked, -1); 2588 + rgrp_unlock_local(rgd); 2589 2589 2590 2590 gfs2_statfs_change(sdp, 0, +1, -1); 2591 2591 trace_gfs2_block_alloc(ip, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE);
+154 -61
fs/gfs2/super.c
··· 332 332 struct lfcc *lfcc; 333 333 LIST_HEAD(list); 334 334 struct gfs2_log_header_host lh; 335 - int error; 335 + int error, error2; 336 + 337 + /* 338 + * Grab all the journal glocks in SH mode. We are *probably* doing 339 + * that to prevent recovery. 340 + */ 336 341 337 342 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { 338 343 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL); ··· 354 349 list_add(&lfcc->list, &list); 355 350 } 356 351 352 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 353 + 357 354 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_EXCLUSIVE, 358 355 LM_FLAG_NOEXP | GL_NOPID, 359 356 &sdp->sd_freeze_gh); 360 357 if (error) 361 - goto out; 358 + goto relock_shared; 362 359 363 360 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { 364 361 error = gfs2_jdesc_check(jd); ··· 375 368 } 376 369 } 377 370 378 - if (error) 379 - gfs2_freeze_unlock(&sdp->sd_freeze_gh); 371 + if (!error) 372 + goto out; /* success */ 373 + 374 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 375 + 376 + relock_shared: 377 + error2 = gfs2_freeze_lock_shared(sdp); 378 + gfs2_assert_withdraw(sdp, !error2); 380 379 381 380 out: 382 381 while (!list_empty(&list)) { ··· 476 463 * @flags: The type of dirty 477 464 * 478 465 * Unfortunately it can be called under any combination of inode 479 - * glock and transaction lock, so we have to check carefully. 466 + * glock and freeze glock, so we have to check carefully. 480 467 * 481 468 * At the moment this deals only with atime - it should be possible 482 469 * to expand that role in future, once a review of the locking has ··· 628 615 629 616 /* Release stuff */ 630 617 618 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 619 + 631 620 iput(sdp->sd_jindex); 632 621 iput(sdp->sd_statfs_inode); 633 622 iput(sdp->sd_rindex); ··· 684 669 return sdp->sd_log_error; 685 670 } 686 671 672 + static int gfs2_freeze_locally(struct gfs2_sbd *sdp) 673 + { 674 + struct super_block *sb = sdp->sd_vfs; 675 + int error; 676 + 677 + error = freeze_super(sb); 678 + if (error) 679 + return error; 680 + 681 + if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { 682 + gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE | 683 + GFS2_LFC_FREEZE_GO_SYNC); 684 + if (gfs2_withdrawn(sdp)) { 685 + thaw_super(sb); 686 + return -EIO; 687 + } 688 + } 689 + return 0; 690 + } 691 + 692 + static int gfs2_do_thaw(struct gfs2_sbd *sdp) 693 + { 694 + struct super_block *sb = sdp->sd_vfs; 695 + int error; 696 + 697 + error = gfs2_freeze_lock_shared(sdp); 698 + if (error) 699 + goto fail; 700 + error = thaw_super(sb); 701 + if (!error) 702 + return 0; 703 + 704 + fail: 705 + fs_info(sdp, "GFS2: couldn't thaw filesystem: %d\n", error); 706 + gfs2_assert_withdraw(sdp, 0); 707 + return error; 708 + } 709 + 687 710 void gfs2_freeze_func(struct work_struct *work) 688 711 { 689 - int error; 690 - struct gfs2_holder freeze_gh; 691 712 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_freeze_work); 692 713 struct super_block *sb = sdp->sd_vfs; 714 + int error; 693 715 694 - atomic_inc(&sb->s_active); 695 - error = gfs2_freeze_lock(sdp, &freeze_gh, 0); 696 - if (error) { 697 - gfs2_assert_withdraw(sdp, 0); 698 - } else { 699 - atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); 700 - error = thaw_super(sb); 701 - if (error) { 702 - fs_info(sdp, "GFS2: couldn't thaw filesystem: %d\n", 703 - error); 704 - gfs2_assert_withdraw(sdp, 0); 705 - } 706 - gfs2_freeze_unlock(&freeze_gh); 707 - } 716 + mutex_lock(&sdp->sd_freeze_mutex); 717 + error = -EBUSY; 718 + if (test_bit(SDF_FROZEN, &sdp->sd_flags)) 719 + goto freeze_failed; 720 + 721 + error = gfs2_freeze_locally(sdp); 722 + if (error) 723 + goto freeze_failed; 724 + 725 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 726 + set_bit(SDF_FROZEN, &sdp->sd_flags); 727 + 728 + error = gfs2_do_thaw(sdp); 729 + if (error) 730 + goto out; 731 + 732 + clear_bit(SDF_FROZEN, &sdp->sd_flags); 733 + goto out; 734 + 735 + freeze_failed: 736 + fs_info(sdp, "GFS2: couldn't freeze filesystem: %d\n", error); 737 + 738 + out: 739 + mutex_unlock(&sdp->sd_freeze_mutex); 708 740 deactivate_super(sb); 709 - clear_bit_unlock(SDF_FS_FROZEN, &sdp->sd_flags); 710 - wake_up_bit(&sdp->sd_flags, SDF_FS_FROZEN); 711 - return; 712 741 } 713 742 714 743 /** 715 - * gfs2_freeze - prevent further writes to the filesystem 744 + * gfs2_freeze_super - prevent further writes to the filesystem 716 745 * @sb: the VFS structure for the filesystem 717 746 * 718 747 */ 719 748 720 - static int gfs2_freeze(struct super_block *sb) 749 + static int gfs2_freeze_super(struct super_block *sb) 721 750 { 722 751 struct gfs2_sbd *sdp = sb->s_fs_info; 723 752 int error; 724 753 725 - mutex_lock(&sdp->sd_freeze_mutex); 726 - if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) { 727 - error = -EBUSY; 754 + if (!mutex_trylock(&sdp->sd_freeze_mutex)) 755 + return -EBUSY; 756 + error = -EBUSY; 757 + if (test_bit(SDF_FROZEN, &sdp->sd_flags)) 728 758 goto out; 729 - } 730 759 731 760 for (;;) { 732 - if (gfs2_withdrawn(sdp)) { 733 - error = -EINVAL; 761 + error = gfs2_freeze_locally(sdp); 762 + if (error) { 763 + fs_info(sdp, "GFS2: couldn't freeze filesystem: %d\n", 764 + error); 734 765 goto out; 735 766 } 736 767 737 768 error = gfs2_lock_fs_check_clean(sdp); 738 769 if (!error) 739 - break; 770 + break; /* success */ 771 + 772 + error = gfs2_do_thaw(sdp); 773 + if (error) 774 + goto out; 740 775 741 776 if (error == -EBUSY) 742 777 fs_err(sdp, "waiting for recovery before freeze\n"); ··· 800 735 fs_err(sdp, "retrying...\n"); 801 736 msleep(1000); 802 737 } 803 - set_bit(SDF_FS_FROZEN, &sdp->sd_flags); 738 + 804 739 out: 740 + if (!error) { 741 + set_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags); 742 + set_bit(SDF_FROZEN, &sdp->sd_flags); 743 + } 805 744 mutex_unlock(&sdp->sd_freeze_mutex); 806 745 return error; 807 746 } 808 747 809 748 /** 810 - * gfs2_unfreeze - reallow writes to the filesystem 749 + * gfs2_thaw_super - reallow writes to the filesystem 811 750 * @sb: the VFS structure for the filesystem 812 751 * 813 752 */ 814 753 815 - static int gfs2_unfreeze(struct super_block *sb) 754 + static int gfs2_thaw_super(struct super_block *sb) 755 + { 756 + struct gfs2_sbd *sdp = sb->s_fs_info; 757 + int error; 758 + 759 + if (!mutex_trylock(&sdp->sd_freeze_mutex)) 760 + return -EBUSY; 761 + error = -EINVAL; 762 + if (!test_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags)) 763 + goto out; 764 + 765 + gfs2_freeze_unlock(&sdp->sd_freeze_gh); 766 + 767 + error = gfs2_do_thaw(sdp); 768 + 769 + if (!error) { 770 + clear_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags); 771 + clear_bit(SDF_FROZEN, &sdp->sd_flags); 772 + } 773 + out: 774 + mutex_unlock(&sdp->sd_freeze_mutex); 775 + return error; 776 + } 777 + 778 + void gfs2_thaw_freeze_initiator(struct super_block *sb) 816 779 { 817 780 struct gfs2_sbd *sdp = sb->s_fs_info; 818 781 819 782 mutex_lock(&sdp->sd_freeze_mutex); 820 - if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || 821 - !gfs2_holder_initialized(&sdp->sd_freeze_gh)) { 822 - mutex_unlock(&sdp->sd_freeze_mutex); 823 - return -EINVAL; 824 - } 783 + if (!test_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags)) 784 + goto out; 825 785 826 786 gfs2_freeze_unlock(&sdp->sd_freeze_gh); 787 + 788 + out: 827 789 mutex_unlock(&sdp->sd_freeze_mutex); 828 - return wait_on_bit(&sdp->sd_flags, SDF_FS_FROZEN, TASK_INTERRUPTIBLE); 829 790 } 830 791 831 792 /** ··· 1095 1004 { 1096 1005 struct gfs2_sbd *sdp = root->d_sb->s_fs_info; 1097 1006 struct gfs2_args *args = &sdp->sd_args; 1098 - int val; 1007 + unsigned int logd_secs, statfs_slow, statfs_quantum, quota_quantum; 1008 + 1009 + spin_lock(&sdp->sd_tune.gt_spin); 1010 + logd_secs = sdp->sd_tune.gt_logd_secs; 1011 + quota_quantum = sdp->sd_tune.gt_quota_quantum; 1012 + statfs_quantum = sdp->sd_tune.gt_statfs_quantum; 1013 + statfs_slow = sdp->sd_tune.gt_statfs_slow; 1014 + spin_unlock(&sdp->sd_tune.gt_spin); 1099 1015 1100 1016 if (is_ancestor(root, sdp->sd_master_dir)) 1101 1017 seq_puts(s, ",meta"); ··· 1157 1059 } 1158 1060 if (args->ar_discard) 1159 1061 seq_puts(s, ",discard"); 1160 - val = sdp->sd_tune.gt_logd_secs; 1161 - if (val != 30) 1162 - seq_printf(s, ",commit=%d", val); 1163 - val = sdp->sd_tune.gt_statfs_quantum; 1164 - if (val != 30) 1165 - seq_printf(s, ",statfs_quantum=%d", val); 1166 - else if (sdp->sd_tune.gt_statfs_slow) 1062 + if (logd_secs != 30) 1063 + seq_printf(s, ",commit=%d", logd_secs); 1064 + if (statfs_quantum != 30) 1065 + seq_printf(s, ",statfs_quantum=%d", statfs_quantum); 1066 + else if (statfs_slow) 1167 1067 seq_puts(s, ",statfs_quantum=0"); 1168 - val = sdp->sd_tune.gt_quota_quantum; 1169 - if (val != 60) 1170 - seq_printf(s, ",quota_quantum=%d", val); 1068 + if (quota_quantum != 60) 1069 + seq_printf(s, ",quota_quantum=%d", quota_quantum); 1171 1070 if (args->ar_statfs_percent) 1172 1071 seq_printf(s, ",statfs_percent=%d", args->ar_statfs_percent); 1173 1072 if (args->ar_errors != GFS2_ERRORS_DEFAULT) { ··· 1226 1131 return -EIO; 1227 1132 } 1228 1133 1229 - error = gfs2_rindex_update(sdp); 1230 - if (error) 1231 - return error; 1134 + gfs2_rindex_update(sdp); 1232 1135 1233 1136 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); 1234 1137 if (error) ··· 1427 1334 goto out; 1428 1335 } 1429 1336 1430 - if (ip->i_gl) 1431 - gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); 1432 - 1433 1337 /* 1434 1338 * As soon as we clear the bitmap for the dinode, gfs2_create_inode() 1435 1339 * can get called to recreate it, or even gfs2_inode_lookup() if the ··· 1440 1350 */ 1441 1351 1442 1352 ret = gfs2_dinode_dealloc(ip); 1353 + if (!ret && ip->i_gl) 1354 + gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); 1355 + 1443 1356 out: 1444 1357 return ret; 1445 1358 } ··· 1621 1528 .evict_inode = gfs2_evict_inode, 1622 1529 .put_super = gfs2_put_super, 1623 1530 .sync_fs = gfs2_sync_fs, 1624 - .freeze_super = gfs2_freeze, 1625 - .thaw_super = gfs2_unfreeze, 1531 + .freeze_super = gfs2_freeze_super, 1532 + .thaw_super = gfs2_thaw_super, 1626 1533 .statfs = gfs2_statfs, 1627 1534 .drop_inode = gfs2_drop_inode, 1628 1535 .show_options = gfs2_show_options,
+1
fs/gfs2/super.h
··· 46 46 extern void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh); 47 47 extern int gfs2_statfs_sync(struct super_block *sb, int type); 48 48 extern void gfs2_freeze_func(struct work_struct *work); 49 + extern void gfs2_thaw_freeze_initiator(struct super_block *sb); 49 50 50 51 extern void free_local_statfs_inodes(struct gfs2_sbd *sdp); 51 52 extern struct inode *find_local_statfs_inode(struct gfs2_sbd *sdp,
+3 -1
fs/gfs2/sys.c
··· 82 82 "RO Recovery: %d\n" 83 83 "Skip DLM Unlock: %d\n" 84 84 "Force AIL Flush: %d\n" 85 + "FS Freeze Initiator: %d\n" 85 86 "FS Frozen: %d\n" 86 87 "Withdrawing: %d\n" 87 88 "Withdraw In Prog: %d\n" ··· 112 111 test_bit(SDF_RORECOVERY, &f), 113 112 test_bit(SDF_SKIP_DLM_UNLOCK, &f), 114 113 test_bit(SDF_FORCE_AIL_FLUSH, &f), 115 - test_bit(SDF_FS_FROZEN, &f), 114 + test_bit(SDF_FREEZE_INITIATOR, &f), 115 + test_bit(SDF_FROZEN, &f), 116 116 test_bit(SDF_WITHDRAWING, &f), 117 117 test_bit(SDF_WITHDRAW_IN_PROG, &f), 118 118 test_bit(SDF_REMOTE_WITHDRAW, &f),
+1 -2
fs/gfs2/trans.c
··· 233 233 struct gfs2_bufdata *bd; 234 234 struct gfs2_meta_header *mh; 235 235 struct gfs2_trans *tr = current->journal_info; 236 - enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); 237 236 238 237 lock_buffer(bh); 239 238 if (buffer_pinned(bh)) { ··· 266 267 (unsigned long long)bd->bd_bh->b_blocknr); 267 268 BUG(); 268 269 } 269 - if (unlikely(state == SFS_FROZEN)) { 270 + if (unlikely(test_bit(SDF_FROZEN, &sdp->sd_flags))) { 270 271 fs_info(sdp, "GFS2:adding buf while frozen\n"); 271 272 gfs2_assert_withdraw(sdp, 0); 272 273 }
+15 -32
fs/gfs2/util.c
··· 93 93 } 94 94 95 95 /** 96 - * gfs2_freeze_lock - hold the freeze glock 96 + * gfs2_freeze_lock_shared - hold the freeze glock 97 97 * @sdp: the superblock 98 - * @freeze_gh: pointer to the requested holder 99 - * @caller_flags: any additional flags needed by the caller 100 98 */ 101 - int gfs2_freeze_lock(struct gfs2_sbd *sdp, struct gfs2_holder *freeze_gh, 102 - int caller_flags) 99 + int gfs2_freeze_lock_shared(struct gfs2_sbd *sdp) 103 100 { 104 - int flags = LM_FLAG_NOEXP | GL_EXACT | caller_flags; 105 101 int error; 106 102 107 - error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, flags, 108 - freeze_gh); 109 - if (error && error != GLR_TRYFAILED) 110 - fs_err(sdp, "can't lock the freeze lock: %d\n", error); 103 + error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, 104 + LM_FLAG_NOEXP | GL_EXACT, 105 + &sdp->sd_freeze_gh); 106 + if (error) 107 + fs_err(sdp, "can't lock the freeze glock: %d\n", error); 111 108 return error; 112 109 } 113 110 ··· 121 124 struct gfs2_inode *ip; 122 125 struct gfs2_glock *i_gl; 123 126 u64 no_formal_ino; 124 - int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 125 127 int ret = 0; 126 128 int tries; 127 129 ··· 148 152 */ 149 153 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 150 154 if (!sb_rdonly(sdp->sd_vfs)) { 151 - struct gfs2_holder freeze_gh; 155 + bool locked = mutex_trylock(&sdp->sd_freeze_mutex); 152 156 153 - gfs2_holder_mark_uninitialized(&freeze_gh); 154 - if (sdp->sd_freeze_gl && 155 - !gfs2_glock_is_locked_by_me(sdp->sd_freeze_gl)) { 156 - ret = gfs2_freeze_lock(sdp, &freeze_gh, 157 - log_write_allowed ? 0 : LM_FLAG_TRY); 158 - if (ret == GLR_TRYFAILED) 159 - ret = 0; 160 - } 161 - if (!ret) 162 - gfs2_make_fs_ro(sdp); 157 + gfs2_make_fs_ro(sdp); 158 + 159 + if (locked) 160 + mutex_unlock(&sdp->sd_freeze_mutex); 161 + 163 162 /* 164 163 * Dequeue any pending non-system glock holders that can no 165 164 * longer be granted because the file system is withdrawn. 166 165 */ 167 166 gfs2_gl_dq_holders(sdp); 168 - gfs2_freeze_unlock(&freeze_gh); 169 167 } 170 168 171 169 if (sdp->sd_lockstruct.ls_ops->lm_lock == NULL) { /* lock_nolock */ ··· 177 187 } 178 188 sdp->sd_jinode_gh.gh_flags |= GL_NOCACHE; 179 189 gfs2_glock_dq(&sdp->sd_jinode_gh); 180 - if (test_bit(SDF_FS_FROZEN, &sdp->sd_flags)) { 181 - /* Make sure gfs2_unfreeze works if partially-frozen */ 182 - flush_work(&sdp->sd_freeze_work); 183 - atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); 184 - thaw_super(sdp->sd_vfs); 185 - } else { 186 - wait_on_bit(&i_gl->gl_flags, GLF_DEMOTE, 187 - TASK_UNINTERRUPTIBLE); 188 - } 190 + gfs2_thaw_freeze_initiator(sdp->sd_vfs); 191 + wait_on_bit(&i_gl->gl_flags, GLF_DEMOTE, TASK_UNINTERRUPTIBLE); 189 192 190 193 /* 191 194 * holder_uninit to force glock_put, to force dlm to let go
+1 -2
fs/gfs2/util.h
··· 149 149 150 150 extern int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd, 151 151 bool verbose); 152 - extern int gfs2_freeze_lock(struct gfs2_sbd *sdp, 153 - struct gfs2_holder *freeze_gh, int caller_flags); 152 + extern int gfs2_freeze_lock_shared(struct gfs2_sbd *sdp); 154 153 extern void gfs2_freeze_unlock(struct gfs2_holder *freeze_gh); 155 154 156 155 #define gfs2_io_error(sdp) \