ffs_snapshot.c (52488b514897b5c2c2601008d94bb5a905d6f401) | ffs_snapshot.c (34816cb9aeca7b0ad3289c2de04cad0cd1b111ed) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. 5 * 6 * Further information about snapshots can be obtained from: 7 * 8 * Marshall Kirk McKusick http://www.mckusick.com/softdep/ --- 466 unchanged lines hidden (view full) --- 475 goto out1; 476 } 477 /* 478 * Grab a copy of the superblock and its summary information. 479 * We delay writing it until the suspension is released below. 480 */ 481 copy_fs = malloc((u_long)fs->fs_bsize, M_UFSMNT, M_WAITOK); 482 bcopy(fs, copy_fs, fs->fs_sbsize); | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. 5 * 6 * Further information about snapshots can be obtained from: 7 * 8 * Marshall Kirk McKusick http://www.mckusick.com/softdep/ --- 466 unchanged lines hidden (view full) --- 475 goto out1; 476 } 477 /* 478 * Grab a copy of the superblock and its summary information. 479 * We delay writing it until the suspension is released below. 480 */ 481 copy_fs = malloc((u_long)fs->fs_bsize, M_UFSMNT, M_WAITOK); 482 bcopy(fs, copy_fs, fs->fs_sbsize); |
483 copy_fs->fs_si = malloc(sizeof(struct fs_summary_info), M_UFSMNT, 484 M_ZERO | M_WAITOK); |
|
483 if ((fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) 484 copy_fs->fs_clean = 1; 485 size = fs->fs_bsize < SBLOCKSIZE ? fs->fs_bsize : SBLOCKSIZE; 486 if (fs->fs_sbsize < size) 487 bzero(&((char *)copy_fs)[fs->fs_sbsize], 488 size - fs->fs_sbsize); 489 size = blkroundup(fs, fs->fs_cssize); 490 if (fs->fs_contigsumsize > 0) --- 5 unchanged lines hidden (view full) --- 496 loc = howmany(fs->fs_cssize, fs->fs_fsize); 497 i = fs->fs_frag - loc % fs->fs_frag; 498 len = (i == fs->fs_frag) ? 0 : i * fs->fs_fsize; 499 if (len > 0) { 500 if ((error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + loc), 501 len, KERNCRED, &bp)) != 0) { 502 brelse(bp); 503 free(copy_fs->fs_csp, M_UFSMNT); | 485 if ((fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) 486 copy_fs->fs_clean = 1; 487 size = fs->fs_bsize < SBLOCKSIZE ? fs->fs_bsize : SBLOCKSIZE; 488 if (fs->fs_sbsize < size) 489 bzero(&((char *)copy_fs)[fs->fs_sbsize], 490 size - fs->fs_sbsize); 491 size = blkroundup(fs, fs->fs_cssize); 492 if (fs->fs_contigsumsize > 0) --- 5 unchanged lines hidden (view full) --- 498 loc = howmany(fs->fs_cssize, fs->fs_fsize); 499 i = fs->fs_frag - loc % fs->fs_frag; 500 len = (i == fs->fs_frag) ? 0 : i * fs->fs_fsize; 501 if (len > 0) { 502 if ((error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + loc), 503 len, KERNCRED, &bp)) != 0) { 504 brelse(bp); 505 free(copy_fs->fs_csp, M_UFSMNT); |
506 free(copy_fs->fs_si, M_UFSMNT); |
|
504 free(copy_fs, M_UFSMNT); 505 copy_fs = NULL; 506 goto out1; 507 } 508 bcopy(bp->b_data, space, (u_int)len); 509 space = (char *)space + len; 510 bp->b_flags |= B_INVAL | B_NOCACHE; 511 brelse(bp); --- 94 unchanged lines hidden (view full) --- 606 DIP_SET(xp, i_db[loc], blkno); 607 if (!error) 608 error = ffs_freefile(ump, copy_fs, vp, xp->i_number, 609 xp->i_mode, NULL); 610 VOP_UNLOCK(xvp); 611 vdrop(xvp); 612 if (error) { 613 free(copy_fs->fs_csp, M_UFSMNT); | 507 free(copy_fs, M_UFSMNT); 508 copy_fs = NULL; 509 goto out1; 510 } 511 bcopy(bp->b_data, space, (u_int)len); 512 space = (char *)space + len; 513 bp->b_flags |= B_INVAL | B_NOCACHE; 514 brelse(bp); --- 94 unchanged lines hidden (view full) --- 609 DIP_SET(xp, i_db[loc], blkno); 610 if (!error) 611 error = ffs_freefile(ump, copy_fs, vp, xp->i_number, 612 xp->i_mode, NULL); 613 VOP_UNLOCK(xvp); 614 vdrop(xvp); 615 if (error) { 616 free(copy_fs->fs_csp, M_UFSMNT); |
617 free(copy_fs->fs_si, M_UFSMNT); |
|
614 free(copy_fs, M_UFSMNT); 615 copy_fs = NULL; 616 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); 617 goto out1; 618 } 619 } 620 /* 621 * Erase the journal file from the snapshot. 622 */ 623 if (fs->fs_flags & FS_SUJ) { 624 error = softdep_journal_lookup(mp, &xvp); 625 if (error) { 626 free(copy_fs->fs_csp, M_UFSMNT); | 618 free(copy_fs, M_UFSMNT); 619 copy_fs = NULL; 620 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); 621 goto out1; 622 } 623 } 624 /* 625 * Erase the journal file from the snapshot. 626 */ 627 if (fs->fs_flags & FS_SUJ) { 628 error = softdep_journal_lookup(mp, &xvp); 629 if (error) { 630 free(copy_fs->fs_csp, M_UFSMNT); |
631 free(copy_fs->fs_si, M_UFSMNT); |
|
627 free(copy_fs, M_UFSMNT); 628 copy_fs = NULL; 629 goto out1; 630 } 631 xp = VTOI(xvp); 632 if (I_IS_UFS1(xp)) 633 error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, 634 BLK_NOCOPY, 0); --- 202 unchanged lines hidden (view full) --- 837 break; 838 error = readblock(vp, bp, blockno); 839 bawrite(bp); 840 if (error != 0) 841 break; 842 } 843done: 844 free(copy_fs->fs_csp, M_UFSMNT); | 632 free(copy_fs, M_UFSMNT); 633 copy_fs = NULL; 634 goto out1; 635 } 636 xp = VTOI(xvp); 637 if (I_IS_UFS1(xp)) 638 error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, 639 BLK_NOCOPY, 0); --- 202 unchanged lines hidden (view full) --- 842 break; 843 error = readblock(vp, bp, blockno); 844 bawrite(bp); 845 if (error != 0) 846 break; 847 } 848done: 849 free(copy_fs->fs_csp, M_UFSMNT); |
850 free(copy_fs->fs_si, M_UFSMNT); |
|
845 free(copy_fs, M_UFSMNT); 846 copy_fs = NULL; 847out: 848 NDFREE(&nd, NDF_ONLY_PNBUF); 849 if (saved_nice > 0) { 850 struct proc *p; 851 852 p = td->td_proc; --- 1862 unchanged lines hidden --- | 851 free(copy_fs, M_UFSMNT); 852 copy_fs = NULL; 853out: 854 NDFREE(&nd, NDF_ONLY_PNBUF); 855 if (saved_nice > 0) { 856 struct proc *p; 857 858 p = td->td_proc; --- 1862 unchanged lines hidden --- |