zfs_znode.c (243488) | zfs_znode.c (243674) |
---|---|
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 --- 6 unchanged lines hidden (view full) --- 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 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 --- 6 unchanged lines hidden (view full) --- 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2012 by Delphix. All rights reserved. |
|
23 */ 24 25/* Portions Copyright 2007 Jeremy Teo */ 26/* Portions Copyright 2011 Martin Matuska <mm@FreeBSD.org> */ 27 28#ifdef _KERNEL 29#include <sys/types.h> 30#include <sys/param.h> --- 799 unchanged lines hidden (view full) --- 830 * that there will be an i/o error and we will fail one of the 831 * assertions below. 832 */ 833 if (vap->va_type == VDIR) { 834 if (zfsvfs->z_replay) { 835 err = zap_create_claim_norm(zfsvfs->z_os, obj, 836 zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, 837 obj_type, bonuslen, tx); | 24 */ 25 26/* Portions Copyright 2007 Jeremy Teo */ 27/* Portions Copyright 2011 Martin Matuska <mm@FreeBSD.org> */ 28 29#ifdef _KERNEL 30#include <sys/types.h> 31#include <sys/param.h> --- 799 unchanged lines hidden (view full) --- 831 * that there will be an i/o error and we will fail one of the 832 * assertions below. 833 */ 834 if (vap->va_type == VDIR) { 835 if (zfsvfs->z_replay) { 836 err = zap_create_claim_norm(zfsvfs->z_os, obj, 837 zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, 838 obj_type, bonuslen, tx); |
838 ASSERT3U(err, ==, 0); | 839 ASSERT0(err); |
839 } else { 840 obj = zap_create_norm(zfsvfs->z_os, 841 zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, 842 obj_type, bonuslen, tx); 843 } 844 } else { 845 if (zfsvfs->z_replay) { 846 err = dmu_object_claim(zfsvfs->z_os, obj, 847 DMU_OT_PLAIN_FILE_CONTENTS, 0, 848 obj_type, bonuslen, tx); | 840 } else { 841 obj = zap_create_norm(zfsvfs->z_os, 842 zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, 843 obj_type, bonuslen, tx); 844 } 845 } else { 846 if (zfsvfs->z_replay) { 847 err = dmu_object_claim(zfsvfs->z_os, obj, 848 DMU_OT_PLAIN_FILE_CONTENTS, 0, 849 obj_type, bonuslen, tx); |
849 ASSERT3U(err, ==, 0); | 850 ASSERT0(err); |
850 } else { 851 obj = dmu_object_alloc(zfsvfs->z_os, 852 DMU_OT_PLAIN_FILE_CONTENTS, 0, 853 obj_type, bonuslen, tx); 854 } 855 } 856 857 getnewvnode_reserve(1); --- 166 unchanged lines hidden (view full) --- 1024 (*zpp)->z_mode = mode; 1025 1026 if (vap->va_mask & AT_XVATTR) 1027 zfs_xvattr_set(*zpp, (xvattr_t *)vap, tx); 1028 1029 if (obj_type == DMU_OT_ZNODE || 1030 acl_ids->z_aclp->z_version < ZFS_ACL_VERSION_FUID) { 1031 err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx); | 851 } else { 852 obj = dmu_object_alloc(zfsvfs->z_os, 853 DMU_OT_PLAIN_FILE_CONTENTS, 0, 854 obj_type, bonuslen, tx); 855 } 856 } 857 858 getnewvnode_reserve(1); --- 166 unchanged lines hidden (view full) --- 1025 (*zpp)->z_mode = mode; 1026 1027 if (vap->va_mask & AT_XVATTR) 1028 zfs_xvattr_set(*zpp, (xvattr_t *)vap, tx); 1029 1030 if (obj_type == DMU_OT_ZNODE || 1031 acl_ids->z_aclp->z_version < ZFS_ACL_VERSION_FUID) { 1032 err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx); |
1032 ASSERT3P(err, ==, 0); | 1033 ASSERT0(err); |
1033 } 1034 if (!(flag & IS_ROOT_NODE)) { 1035 vnode_t *vp; 1036 1037 vp = ZTOV(*zpp); 1038 vp->v_vflag |= VV_FORCEINSMQ; 1039 err = insmntque(vp, zfsvfs->z_vfs); 1040 vp->v_vflag &= ~VV_FORCEINSMQ; --- 485 unchanged lines hidden (view full) --- 1526 if (zp->z_blksz && zp->z_size > zp->z_blksz) 1527 return; 1528 1529 error = dmu_object_set_blocksize(zp->z_zfsvfs->z_os, zp->z_id, 1530 size, 0, tx); 1531 1532 if (error == ENOTSUP) 1533 return; | 1034 } 1035 if (!(flag & IS_ROOT_NODE)) { 1036 vnode_t *vp; 1037 1038 vp = ZTOV(*zpp); 1039 vp->v_vflag |= VV_FORCEINSMQ; 1040 err = insmntque(vp, zfsvfs->z_vfs); 1041 vp->v_vflag &= ~VV_FORCEINSMQ; --- 485 unchanged lines hidden (view full) --- 1527 if (zp->z_blksz && zp->z_size > zp->z_blksz) 1528 return; 1529 1530 error = dmu_object_set_blocksize(zp->z_zfsvfs->z_os, zp->z_id, 1531 size, 0, tx); 1532 1533 if (error == ENOTSUP) 1534 return; |
1534 ASSERT3U(error, ==, 0); | 1535 ASSERT0(error); |
1535 1536 /* What blocksize did we actually get? */ 1537 dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &zp->z_blksz, &dummy); 1538} 1539 1540#ifdef sun 1541/* 1542 * This is a dummy interface used when pvn_vplist_dirty() should *not* --- 507 unchanged lines hidden (view full) --- 2050 sa_buf_rele(db, tag); 2051} 2052 2053/* 2054 * Given an object number, return its parent object number and whether 2055 * or not the object is an extended attribute directory. 2056 */ 2057static int | 1536 1537 /* What blocksize did we actually get? */ 1538 dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &zp->z_blksz, &dummy); 1539} 1540 1541#ifdef sun 1542/* 1543 * This is a dummy interface used when pvn_vplist_dirty() should *not* --- 507 unchanged lines hidden (view full) --- 2051 sa_buf_rele(db, tag); 2052} 2053 2054/* 2055 * Given an object number, return its parent object number and whether 2056 * or not the object is an extended attribute directory. 2057 */ 2058static int |
2058zfs_obj_to_pobj(sa_handle_t *hdl, sa_attr_type_t *sa_table, uint64_t *pobjp, 2059 int *is_xattrdir) | 2059zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, 2060 uint64_t *pobjp, int *is_xattrdir) |
2060{ 2061 uint64_t parent; 2062 uint64_t pflags; 2063 uint64_t mode; | 2061{ 2062 uint64_t parent; 2063 uint64_t pflags; 2064 uint64_t mode; |
2065 uint64_t parent_mode; |
|
2064 sa_bulk_attr_t bulk[3]; | 2066 sa_bulk_attr_t bulk[3]; |
2067 sa_handle_t *sa_hdl; 2068 dmu_buf_t *sa_db; |
|
2065 int count = 0; 2066 int error; 2067 2068 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], NULL, 2069 &parent, sizeof (parent)); 2070 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, 2071 &pflags, sizeof (pflags)); 2072 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, 2073 &mode, sizeof (mode)); 2074 2075 if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) 2076 return (error); 2077 | 2069 int count = 0; 2070 int error; 2071 2072 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], NULL, 2073 &parent, sizeof (parent)); 2074 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, 2075 &pflags, sizeof (pflags)); 2076 SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, 2077 &mode, sizeof (mode)); 2078 2079 if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) 2080 return (error); 2081 |
2078 *pobjp = parent; | 2082 /* 2083 * When a link is removed its parent pointer is not changed and will 2084 * be invalid. There are two cases where a link is removed but the 2085 * file stays around, when it goes to the delete queue and when there 2086 * are additional links. 2087 */ 2088 error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG); 2089 if (error != 0) 2090 return (error); 2091 2092 error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode)); 2093 zfs_release_sa_handle(sa_hdl, sa_db, FTAG); 2094 if (error != 0) 2095 return (error); 2096 |
2079 *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); 2080 | 2097 *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); 2098 |
2099 /* 2100 * Extended attributes can be applied to files, directories, etc. 2101 * Otherwise the parent must be a directory. 2102 */ 2103 if (!*is_xattrdir && !S_ISDIR(parent_mode)) 2104 return (EINVAL); 2105 2106 *pobjp = parent; 2107 |
|
2081 return (0); 2082} 2083 2084/* 2085 * Given an object number, return some zpl level statistics 2086 */ 2087static int 2088zfs_obj_to_stats_impl(sa_handle_t *hdl, sa_attr_type_t *sa_table, --- 32 unchanged lines hidden (view full) --- 2121 uint64_t pobj; 2122 char component[MAXNAMELEN + 2]; 2123 size_t complen; 2124 int is_xattrdir; 2125 2126 if (prevdb) 2127 zfs_release_sa_handle(prevhdl, prevdb, FTAG); 2128 | 2108 return (0); 2109} 2110 2111/* 2112 * Given an object number, return some zpl level statistics 2113 */ 2114static int 2115zfs_obj_to_stats_impl(sa_handle_t *hdl, sa_attr_type_t *sa_table, --- 32 unchanged lines hidden (view full) --- 2148 uint64_t pobj; 2149 char component[MAXNAMELEN + 2]; 2150 size_t complen; 2151 int is_xattrdir; 2152 2153 if (prevdb) 2154 zfs_release_sa_handle(prevhdl, prevdb, FTAG); 2155 |
2129 if ((error = zfs_obj_to_pobj(sa_hdl, sa_table, &pobj, | 2156 if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj, |
2130 &is_xattrdir)) != 0) 2131 break; 2132 2133 if (pobj == obj) { 2134 if (path[0] != '/') 2135 *--path = '/'; 2136 break; 2137 } --- 93 unchanged lines hidden --- | 2157 &is_xattrdir)) != 0) 2158 break; 2159 2160 if (pobj == obj) { 2161 if (path[0] != '/') 2162 *--path = '/'; 2163 break; 2164 } --- 93 unchanged lines hidden --- |