dmu_send.c (196703) | dmu_send.c (200726) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 815 unchanged lines hidden (view full) --- 824} 825 826static int 827restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) 828{ 829 int err; 830 dmu_tx_t *tx; 831 | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 815 unchanged lines hidden (view full) --- 824} 825 826static int 827restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) 828{ 829 int err; 830 dmu_tx_t *tx; 831 |
832 err = dmu_object_info(os, drro->drr_object, NULL); 833 834 if (err != 0 && err != ENOENT) 835 return (EINVAL); 836 | |
837 if (drro->drr_type == DMU_OT_NONE || 838 drro->drr_type >= DMU_OT_NUMTYPES || 839 drro->drr_bonustype >= DMU_OT_NUMTYPES || 840 drro->drr_checksum >= ZIO_CHECKSUM_FUNCTIONS || 841 drro->drr_compress >= ZIO_COMPRESS_FUNCTIONS || 842 P2PHASE(drro->drr_blksz, SPA_MINBLOCKSIZE) || 843 drro->drr_blksz < SPA_MINBLOCKSIZE || 844 drro->drr_blksz > SPA_MAXBLOCKSIZE || 845 drro->drr_bonuslen > DN_MAX_BONUSLEN) { 846 return (EINVAL); 847 } 848 | 832 if (drro->drr_type == DMU_OT_NONE || 833 drro->drr_type >= DMU_OT_NUMTYPES || 834 drro->drr_bonustype >= DMU_OT_NUMTYPES || 835 drro->drr_checksum >= ZIO_CHECKSUM_FUNCTIONS || 836 drro->drr_compress >= ZIO_COMPRESS_FUNCTIONS || 837 P2PHASE(drro->drr_blksz, SPA_MINBLOCKSIZE) || 838 drro->drr_blksz < SPA_MINBLOCKSIZE || 839 drro->drr_blksz > SPA_MAXBLOCKSIZE || 840 drro->drr_bonuslen > DN_MAX_BONUSLEN) { 841 return (EINVAL); 842 } 843 |
849 tx = dmu_tx_create(os); | 844 err = dmu_object_info(os, drro->drr_object, NULL); |
850 | 845 |
846 if (err != 0 && err != ENOENT) 847 return (EINVAL); 848 |
|
851 if (err == ENOENT) { 852 /* currently free, want to be allocated */ | 849 if (err == ENOENT) { 850 /* currently free, want to be allocated */ |
851 tx = dmu_tx_create(os); |
|
853 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); | 852 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
854 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, 1); | |
855 err = dmu_tx_assign(tx, TXG_WAIT); 856 if (err) { 857 dmu_tx_abort(tx); 858 return (err); 859 } 860 err = dmu_object_claim(os, drro->drr_object, 861 drro->drr_type, drro->drr_blksz, 862 drro->drr_bonustype, drro->drr_bonuslen, tx); | 853 err = dmu_tx_assign(tx, TXG_WAIT); 854 if (err) { 855 dmu_tx_abort(tx); 856 return (err); 857 } 858 err = dmu_object_claim(os, drro->drr_object, 859 drro->drr_type, drro->drr_blksz, 860 drro->drr_bonustype, drro->drr_bonuslen, tx); |
861 dmu_tx_commit(tx); |
|
863 } else { 864 /* currently allocated, want to be allocated */ | 862 } else { 863 /* currently allocated, want to be allocated */ |
865 dmu_tx_hold_bonus(tx, drro->drr_object); 866 /* 867 * We may change blocksize and delete old content, 868 * so need to hold_write and hold_free. 869 */ 870 dmu_tx_hold_write(tx, drro->drr_object, 0, 1); 871 dmu_tx_hold_free(tx, drro->drr_object, 0, DMU_OBJECT_END); 872 err = dmu_tx_assign(tx, TXG_WAIT); 873 if (err) { 874 dmu_tx_abort(tx); 875 return (err); 876 } | |
877 878 err = dmu_object_reclaim(os, drro->drr_object, 879 drro->drr_type, drro->drr_blksz, | 864 865 err = dmu_object_reclaim(os, drro->drr_object, 866 drro->drr_type, drro->drr_blksz, |
880 drro->drr_bonustype, drro->drr_bonuslen, tx); | 867 drro->drr_bonustype, drro->drr_bonuslen); |
881 } | 868 } |
882 if (err) { 883 dmu_tx_commit(tx); | 869 if (err) |
884 return (EINVAL); | 870 return (EINVAL); |
871 872 tx = dmu_tx_create(os); 873 dmu_tx_hold_bonus(tx, drro->drr_object); 874 err = dmu_tx_assign(tx, TXG_WAIT); 875 if (err) { 876 dmu_tx_abort(tx); 877 return (err); |
|
885 } 886 887 dmu_object_set_checksum(os, drro->drr_object, drro->drr_checksum, tx); 888 dmu_object_set_compress(os, drro->drr_object, drro->drr_compress, tx); 889 890 if (drro->drr_bonuslen) { 891 dmu_buf_t *db; 892 void *data; --- 345 unchanged lines hidden --- | 878 } 879 880 dmu_object_set_checksum(os, drro->drr_object, drro->drr_checksum, tx); 881 dmu_object_set_compress(os, drro->drr_object, drro->drr_compress, tx); 882 883 if (drro->drr_bonuslen) { 884 dmu_buf_t *db; 885 void *data; --- 345 unchanged lines hidden --- |