zfs_dir.c (208131) | zfs_dir.c (209962) |
---|---|
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 --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* | 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 --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* |
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. 24 */ 25 26#include <sys/types.h> 27#include <sys/param.h> 28#include <sys/time.h> 29#include <sys/systm.h> 30#include <sys/sysmacros.h> --- 545 unchanged lines hidden (view full) --- 576 znode_t *xzp = NULL; 577 dmu_tx_t *tx; 578 uint64_t acl_obj; 579 int error; 580 581 ASSERT(zp->z_phys->zp_links == 0); 582 583 /* | 23 * Use is subject to license terms. 24 */ 25 26#include <sys/types.h> 27#include <sys/param.h> 28#include <sys/time.h> 29#include <sys/systm.h> 30#include <sys/sysmacros.h> --- 545 unchanged lines hidden (view full) --- 576 znode_t *xzp = NULL; 577 dmu_tx_t *tx; 578 uint64_t acl_obj; 579 int error; 580 581 ASSERT(zp->z_phys->zp_links == 0); 582 583 /* |
584 * If this is a ZIL replay then leave the object in the unlinked set. 585 * Otherwise we can get a deadlock, because the delete can be 586 * quite large and span multiple tx's and txgs, but each replay 587 * creates a tx to atomically run the replay function and mark the 588 * replay record as complete. We deadlock trying to start a tx in 589 * a new txg to further the deletion but can't because the replay 590 * tx hasn't finished. 591 * 592 * We actually delete the object if we get a failure to create an 593 * object in zil_replay_log_record(), or after calling zil_replay(). 594 */ 595 if (zfsvfs->z_assign >= TXG_INITIAL) { 596 zfs_znode_dmu_fini(zp); 597 zfs_znode_free(zp); 598 return; 599 } 600 601 /* | |
602 * If this is an attribute directory, purge its contents. 603 */ 604 if (ZTOV(zp) != NULL && ZTOV(zp)->v_type == VDIR && 605 (zp->z_phys->zp_flags & ZFS_XATTR)) { 606 if (zfs_purgedir(zp) != 0) { 607 /* 608 * Not enough space to delete some xattrs. 609 * Leave it in the unlinked set. --- 227 unchanged lines hidden (view full) --- 837 838int 839zfs_make_xattrdir(znode_t *zp, vattr_t *vap, vnode_t **xvpp, cred_t *cr) 840{ 841 zfsvfs_t *zfsvfs = zp->z_zfsvfs; 842 znode_t *xzp; 843 dmu_tx_t *tx; 844 int error; | 584 * If this is an attribute directory, purge its contents. 585 */ 586 if (ZTOV(zp) != NULL && ZTOV(zp)->v_type == VDIR && 587 (zp->z_phys->zp_flags & ZFS_XATTR)) { 588 if (zfs_purgedir(zp) != 0) { 589 /* 590 * Not enough space to delete some xattrs. 591 * Leave it in the unlinked set. --- 227 unchanged lines hidden (view full) --- 819 820int 821zfs_make_xattrdir(znode_t *zp, vattr_t *vap, vnode_t **xvpp, cred_t *cr) 822{ 823 zfsvfs_t *zfsvfs = zp->z_zfsvfs; 824 znode_t *xzp; 825 dmu_tx_t *tx; 826 int error; |
845 zfs_fuid_info_t *fuidp = NULL; | 827 zfs_acl_ids_t acl_ids; 828 boolean_t fuid_dirtied; |
846 847 *xvpp = NULL; 848 849 /* 850 * In FreeBSD, access checking for creating an EA is being done 851 * in zfs_setextattr(), 852 */ 853#ifndef __FreeBSD__ 854 if (error = zfs_zaccess(zp, ACE_WRITE_NAMED_ATTRS, 0, B_FALSE, cr)) 855 return (error); 856#endif 857 | 829 830 *xvpp = NULL; 831 832 /* 833 * In FreeBSD, access checking for creating an EA is being done 834 * in zfs_setextattr(), 835 */ 836#ifndef __FreeBSD__ 837 if (error = zfs_zaccess(zp, ACE_WRITE_NAMED_ATTRS, 0, B_FALSE, cr)) 838 return (error); 839#endif 840 |
841 if ((error = zfs_acl_ids_create(zp, IS_XATTR, vap, cr, NULL, 842 &acl_ids)) != 0) 843 return (error); 844 if (zfs_acl_ids_overquota(zfsvfs, &acl_ids)) { 845 zfs_acl_ids_free(&acl_ids); 846 return (EDQUOT); 847 } 848 |
|
858 tx = dmu_tx_create(zfsvfs->z_os); 859 dmu_tx_hold_bonus(tx, zp->z_id); 860 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); | 849 tx = dmu_tx_create(zfsvfs->z_os); 850 dmu_tx_hold_bonus(tx, zp->z_id); 851 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); |
861 if (IS_EPHEMERAL(crgetuid(cr)) || IS_EPHEMERAL(crgetgid(cr))) { 862 if (zfsvfs->z_fuid_obj == 0) { 863 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); 864 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, 865 FUID_SIZE_ESTIMATE(zfsvfs)); 866 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); 867 } else { 868 dmu_tx_hold_bonus(tx, zfsvfs->z_fuid_obj); 869 dmu_tx_hold_write(tx, zfsvfs->z_fuid_obj, 0, 870 FUID_SIZE_ESTIMATE(zfsvfs)); 871 } 872 } 873 error = dmu_tx_assign(tx, zfsvfs->z_assign); | 852 fuid_dirtied = zfsvfs->z_fuid_dirty; 853 if (fuid_dirtied) 854 zfs_fuid_txhold(zfsvfs, tx); 855 error = dmu_tx_assign(tx, TXG_NOWAIT); |
874 if (error) { | 856 if (error) { |
875 if (error == ERESTART && zfsvfs->z_assign == TXG_NOWAIT) | 857 zfs_acl_ids_free(&acl_ids); 858 if (error == ERESTART) |
876 dmu_tx_wait(tx); 877 dmu_tx_abort(tx); 878 return (error); 879 } | 859 dmu_tx_wait(tx); 860 dmu_tx_abort(tx); 861 return (error); 862 } |
880 zfs_mknode(zp, vap, tx, cr, IS_XATTR, &xzp, 0, NULL, &fuidp); | 863 zfs_mknode(zp, vap, tx, cr, IS_XATTR, &xzp, 0, &acl_ids); 864 865 if (fuid_dirtied) 866 zfs_fuid_sync(zfsvfs, tx); 867 |
881 ASSERT(xzp->z_phys->zp_parent == zp->z_id); 882 dmu_buf_will_dirty(zp->z_dbuf, tx); 883 zp->z_phys->zp_xattr = xzp->z_id; 884 885 (void) zfs_log_create(zfsvfs->z_log, tx, TX_MKXATTR, zp, | 868 ASSERT(xzp->z_phys->zp_parent == zp->z_id); 869 dmu_buf_will_dirty(zp->z_dbuf, tx); 870 zp->z_phys->zp_xattr = xzp->z_id; 871 872 (void) zfs_log_create(zfsvfs->z_log, tx, TX_MKXATTR, zp, |
886 xzp, "", NULL, fuidp, vap); 887 if (fuidp) 888 zfs_fuid_info_free(fuidp); | 873 xzp, "", NULL, acl_ids.z_fuidp, vap); 874 875 zfs_acl_ids_free(&acl_ids); |
889 dmu_tx_commit(tx); 890 891 *xvpp = ZTOV(xzp); 892 893 return (0); 894} 895 896/* --- 57 unchanged lines hidden (view full) --- 954 va.va_mask = AT_TYPE | AT_MODE | AT_UID | AT_GID; 955 va.va_type = VDIR; 956 va.va_mode = S_IFDIR | S_ISVTX | 0777; 957 zfs_fuid_map_ids(zp, cr, &va.va_uid, &va.va_gid); 958 959 error = zfs_make_xattrdir(zp, &va, xvpp, cr); 960 zfs_dirent_unlock(dl); 961 | 876 dmu_tx_commit(tx); 877 878 *xvpp = ZTOV(xzp); 879 880 return (0); 881} 882 883/* --- 57 unchanged lines hidden (view full) --- 941 va.va_mask = AT_TYPE | AT_MODE | AT_UID | AT_GID; 942 va.va_type = VDIR; 943 va.va_mode = S_IFDIR | S_ISVTX | 0777; 944 zfs_fuid_map_ids(zp, cr, &va.va_uid, &va.va_gid); 945 946 error = zfs_make_xattrdir(zp, &va, xvpp, cr); 947 zfs_dirent_unlock(dl); 948 |
962 if (error == ERESTART && zfsvfs->z_assign == TXG_NOWAIT) { | 949 if (error == ERESTART) { |
963 /* NB: we already did dmu_tx_wait() if necessary */ 964 goto top; 965 } 966 if (error == 0) 967 VOP_UNLOCK(*xvpp, 0); 968 969 return (error); 970} --- 14 unchanged lines hidden (view full) --- 985int 986zfs_sticky_remove_access(znode_t *zdp, znode_t *zp, cred_t *cr) 987{ 988 uid_t uid; 989 uid_t downer; 990 uid_t fowner; 991 zfsvfs_t *zfsvfs = zdp->z_zfsvfs; 992 | 950 /* NB: we already did dmu_tx_wait() if necessary */ 951 goto top; 952 } 953 if (error == 0) 954 VOP_UNLOCK(*xvpp, 0); 955 956 return (error); 957} --- 14 unchanged lines hidden (view full) --- 972int 973zfs_sticky_remove_access(znode_t *zdp, znode_t *zp, cred_t *cr) 974{ 975 uid_t uid; 976 uid_t downer; 977 uid_t fowner; 978 zfsvfs_t *zfsvfs = zdp->z_zfsvfs; 979 |
993 if (zdp->z_zfsvfs->z_assign >= TXG_INITIAL) /* ZIL replay */ | 980 if (zdp->z_zfsvfs->z_replay) |
994 return (0); 995 996 if ((zdp->z_phys->zp_mode & S_ISVTX) == 0) 997 return (0); 998 999 downer = zfs_fuid_map_id(zfsvfs, zdp->z_phys->zp_uid, cr, ZFS_OWNER); 1000 fowner = zfs_fuid_map_id(zfsvfs, zp->z_phys->zp_uid, cr, ZFS_OWNER); 1001 1002 if ((uid = crgetuid(cr)) == downer || uid == fowner || 1003 (ZTOV(zp)->v_type == VREG && 1004 zfs_zaccess(zp, ACE_WRITE_DATA, 0, B_FALSE, cr) == 0)) 1005 return (0); 1006 else 1007 return (secpolicy_vnode_remove(ZTOV(zp), cr)); 1008} | 981 return (0); 982 983 if ((zdp->z_phys->zp_mode & S_ISVTX) == 0) 984 return (0); 985 986 downer = zfs_fuid_map_id(zfsvfs, zdp->z_phys->zp_uid, cr, ZFS_OWNER); 987 fowner = zfs_fuid_map_id(zfsvfs, zp->z_phys->zp_uid, cr, ZFS_OWNER); 988 989 if ((uid = crgetuid(cr)) == downer || uid == fowner || 990 (ZTOV(zp)->v_type == VREG && 991 zfs_zaccess(zp, ACE_WRITE_DATA, 0, B_FALSE, cr) == 0)) 992 return (0); 993 else 994 return (secpolicy_vnode_remove(ZTOV(zp), cr)); 995} |