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 --- 264 unchanged lines hidden (view full) --- 273 vsecattr_t vsec = { 0 }; 274 lr_attr_t *lrattr; 275 void *aclstart; 276 void *fuidstart; 277 size_t xvatlen = 0; 278 uint64_t txtype; 279 int error; 280 |
281 txtype = (lr->lr_common.lrc_txtype & ~TX_CI); |
282 if (byteswap) { 283 byteswap_uint64_array(lracl, sizeof (*lracl)); |
284 if (txtype == TX_CREATE_ACL_ATTR || 285 txtype == TX_MKDIR_ACL_ATTR) { 286 lrattr = (lr_attr_t *)(caddr_t)(lracl + 1); 287 zfs_replay_swap_attrs(lrattr); 288 xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); 289 } 290 291 aclstart = (caddr_t)(lracl + 1) + xvatlen; --- 24 unchanged lines hidden (view full) --- 316 xva.xva_vattr.va_nblocks = lr->lr_gen; 317 318 error = dmu_object_info(zfsvfs->z_os, lr->lr_foid, NULL); 319 if (error != ENOENT) 320 goto bail; 321 322 if (lr->lr_common.lrc_txtype & TX_CI) 323 vflg |= FIGNORECASE; |
324 switch (txtype) { |
325 case TX_CREATE_ACL: 326 aclstart = (caddr_t)(lracl + 1); 327 fuidstart = (caddr_t)aclstart + 328 ZIL_ACE_LENGTH(lracl->lr_acl_bytes); 329 zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, 330 (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, 331 lr->lr_uid, lr->lr_gid); 332 /*FALLTHROUGH*/ --- 64 unchanged lines hidden (view full) --- 397 } 398 399bail: 400 if (error == 0 && vp != NULL) 401 VN_RELE(vp); 402 403 VN_RELE(ZTOV(dzp)); 404 |
405 if (zfsvfs->z_fuid_replay) 406 zfs_fuid_info_free(zfsvfs->z_fuid_replay); |
407 zfsvfs->z_fuid_replay = NULL; 408 409 return (error); 410} 411 412static int 413zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap) 414{ --- 6 unchanged lines hidden (view full) --- 421 size_t lrsize = sizeof (lr_create_t); 422 lr_attr_t *lrattr; 423 void *start; 424 size_t xvatlen; 425 uint64_t txtype; 426 struct componentname cn; 427 int error; 428 |
429 txtype = (lr->lr_common.lrc_txtype & ~TX_CI); |
430 if (byteswap) { 431 byteswap_uint64_array(lr, sizeof (*lr)); |
432 if (txtype == TX_CREATE_ATTR || txtype == TX_MKDIR_ATTR) 433 zfs_replay_swap_attrs((lr_attr_t *)(lr + 1)); 434 } 435 436 437 if ((error = zfs_zget(zfsvfs, lr->lr_doid, &dzp)) != 0) 438 return (error); 439 --- 33 unchanged lines hidden (view full) --- 473 lr->lr_uid, lr->lr_gid); 474 } 475 476 cn.cn_cred = kcred; 477 cn.cn_thread = curthread; 478 cn.cn_flags = SAVENAME; 479 480 vn_lock(ZTOV(dzp), LK_EXCLUSIVE | LK_RETRY); |
481 switch (txtype) { |
482 case TX_CREATE_ATTR: 483 lrattr = (lr_attr_t *)(caddr_t)(lr + 1); 484 xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); 485 zfs_replay_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), &xva); 486 start = (caddr_t)(lr + 1) + xvatlen; 487 zfsvfs->z_fuid_replay = 488 zfs_replay_fuid_domain(start, &start, 489 lr->lr_uid, lr->lr_gid); --- 215 unchanged lines hidden (view full) --- 705 706static int 707zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap) 708{ 709 char *data = (char *)(lr + 1); /* data follows lr_write_t */ 710 znode_t *zp; 711 int error; 712 ssize_t resid; |
713 uint64_t orig_eof, eod; |
714 715 if (byteswap) 716 byteswap_uint64_array(lr, sizeof (*lr)); 717 718 if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0) { 719 /* 720 * As we can log writes out of order, it's possible the 721 * file has been removed. In this case just drop the write 722 * and return success. 723 */ 724 if (error == ENOENT) 725 error = 0; 726 return (error); 727 } |
728 orig_eof = zp->z_phys->zp_size; 729 eod = lr->lr_offset + lr->lr_length; /* end of data for this write */ |
730 |
731 /* If it's a dmu_sync() block get the data and write the whole block */ 732 if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) 733 zil_get_replay_data(zfsvfs->z_log, lr); 734 |
735 error = vn_rdwr(UIO_WRITE, ZTOV(zp), data, lr->lr_length, 736 lr->lr_offset, UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid); 737 |
738 /* 739 * This may be a write from a dmu_sync() for a whole block, 740 * and may extend beyond the current end of the file. 741 * We can't just replay what was written for this TX_WRITE as 742 * a future TX_WRITE2 may extend the eof and the data for that 743 * write needs to be there. So we write the whole block and 744 * reduce the eof. 745 */ 746 if (orig_eof < zp->z_phys->zp_size) /* file length grew ? */ 747 zp->z_phys->zp_size = eod; 748 |
749 VN_RELE(ZTOV(zp)); 750 751 return (error); 752} 753 |
754/* 755 * TX_WRITE2 are only generated when dmu_sync() returns EALREADY 756 * meaning the pool block is already being synced. So now that we always write 757 * out full blocks, all we have to do is expand the eof if 758 * the file is grown. 759 */ |
760static int |
761zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap) 762{ 763 znode_t *zp; 764 int error; 765 uint64_t end; 766 767 if (byteswap) 768 byteswap_uint64_array(lr, sizeof (*lr)); 769 770 if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0) { 771 /* 772 * As we can log writes out of order, it's possible the 773 * file has been removed. In this case just drop the write 774 * and return success. 775 */ 776 if (error == ENOENT) 777 error = 0; 778 return (error); 779 } 780 781 end = lr->lr_offset + lr->lr_length; 782 if (end > zp->z_phys->zp_size) { 783 ASSERT3U(end - zp->z_phys->zp_size, <, zp->z_blksz); 784 zp->z_phys->zp_size = end; 785 } 786 787 VN_RELE(ZTOV(zp)); 788 789 return (error); 790} 791 792static int |
793zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap) 794{ 795 796 ZFS_LOG(0, "Unexpected code path, report to pjd@FreeBSD.org"); 797 return (EOPNOTSUPP); 798} 799 800static int --- 195 unchanged lines hidden (view full) --- 996 zfs_replay_acl_v0, /* TX_ACL_V0 */ 997 zfs_replay_acl, /* TX_ACL */ 998 zfs_replay_create_acl, /* TX_CREATE_ACL */ 999 zfs_replay_create, /* TX_CREATE_ATTR */ 1000 zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */ 1001 zfs_replay_create_acl, /* TX_MKDIR_ACL */ 1002 zfs_replay_create, /* TX_MKDIR_ATTR */ 1003 zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */ |
1004 zfs_replay_write2, /* TX_WRITE2 */ |
1005}; |