dsl_dir.c (209099) | dsl_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/dmu.h> 27#include <sys/dmu_objset.h> 28#include <sys/dmu_tx.h> 29#include <sys/dsl_dataset.h> 30#include <sys/dsl_dir.h> --- 190 unchanged lines hidden (view full) --- 221 mutex_exit(&dd->dd_lock); 222 } else { 223 result += strlen(dd->dd_myname); 224 } 225 226 return (result); 227} 228 | 23 * Use is subject to license terms. 24 */ 25 26#include <sys/dmu.h> 27#include <sys/dmu_objset.h> 28#include <sys/dmu_tx.h> 29#include <sys/dsl_dataset.h> 30#include <sys/dsl_dir.h> --- 190 unchanged lines hidden (view full) --- 221 mutex_exit(&dd->dd_lock); 222 } else { 223 result += strlen(dd->dd_myname); 224 } 225 226 return (result); 227} 228 |
229int 230dsl_dir_is_private(dsl_dir_t *dd) 231{ 232 int rv = FALSE; 233 234 if (dd->dd_parent && dsl_dir_is_private(dd->dd_parent)) 235 rv = TRUE; 236 if (dataset_name_hidden(dd->dd_myname)) 237 rv = TRUE; 238 return (rv); 239} 240 241 | |
242static int 243getcomponent(const char *path, char *component, const char **nextp) 244{ 245 char *p; | 229static int 230getcomponent(const char *path, char *component, const char **nextp) 231{ 232 char *p; |
246 if (path == NULL) | 233 if ((path == NULL) || (path[0] == '\0')) |
247 return (ENOENT); 248 /* This would be a good place to reserve some namespace... */ 249 p = strpbrk(path, "/@"); 250 if (p && (p[1] == '/' || p[1] == '@')) { 251 /* two separators in a row */ 252 return (EINVAL); 253 } 254 if (p == NULL || p == path) { --- 816 unchanged lines hidden (view full) --- 1071 1072int 1073dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx) 1074{ 1075 dsl_dir_t *dd = arg1; 1076 uint64_t *reservationp = arg2; 1077 uint64_t new_reservation = *reservationp; 1078 uint64_t used, avail; | 234 return (ENOENT); 235 /* This would be a good place to reserve some namespace... */ 236 p = strpbrk(path, "/@"); 237 if (p && (p[1] == '/' || p[1] == '@')) { 238 /* two separators in a row */ 239 return (EINVAL); 240 } 241 if (p == NULL || p == path) { --- 816 unchanged lines hidden (view full) --- 1058 1059int 1060dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx) 1061{ 1062 dsl_dir_t *dd = arg1; 1063 uint64_t *reservationp = arg2; 1064 uint64_t new_reservation = *reservationp; 1065 uint64_t used, avail; |
1079 int64_t delta; | |
1080 | 1066 |
1081 if (new_reservation > INT64_MAX) 1082 return (EOVERFLOW); 1083 | |
1084 /* 1085 * If we are doing the preliminary check in open context, the 1086 * space estimates may be inaccurate. 1087 */ 1088 if (!dmu_tx_is_syncing(tx)) 1089 return (0); 1090 1091 mutex_enter(&dd->dd_lock); 1092 used = dd->dd_phys->dd_used_bytes; | 1067 /* 1068 * If we are doing the preliminary check in open context, the 1069 * space estimates may be inaccurate. 1070 */ 1071 if (!dmu_tx_is_syncing(tx)) 1072 return (0); 1073 1074 mutex_enter(&dd->dd_lock); 1075 used = dd->dd_phys->dd_used_bytes; |
1093 delta = MAX(used, new_reservation) - 1094 MAX(used, dd->dd_phys->dd_reserved); | |
1095 mutex_exit(&dd->dd_lock); 1096 1097 if (dd->dd_parent) { 1098 avail = dsl_dir_space_available(dd->dd_parent, 1099 NULL, 0, FALSE); 1100 } else { 1101 avail = dsl_pool_adjustedsize(dd->dd_pool, B_FALSE) - used; 1102 } 1103 | 1076 mutex_exit(&dd->dd_lock); 1077 1078 if (dd->dd_parent) { 1079 avail = dsl_dir_space_available(dd->dd_parent, 1080 NULL, 0, FALSE); 1081 } else { 1082 avail = dsl_pool_adjustedsize(dd->dd_pool, B_FALSE) - used; 1083 } 1084 |
1104 if (delta > 0 && delta > avail) 1105 return (ENOSPC); 1106 if (delta > 0 && dd->dd_phys->dd_quota > 0 && 1107 new_reservation > dd->dd_phys->dd_quota) 1108 return (ENOSPC); | 1085 if (MAX(used, new_reservation) > MAX(used, dd->dd_phys->dd_reserved)) { 1086 uint64_t delta = MAX(used, new_reservation) - 1087 MAX(used, dd->dd_phys->dd_reserved); 1088 1089 if (delta > avail) 1090 return (ENOSPC); 1091 if (dd->dd_phys->dd_quota > 0 && 1092 new_reservation > dd->dd_phys->dd_quota) 1093 return (ENOSPC); 1094 } 1095 |
1109 return (0); 1110} 1111 1112/* ARGSUSED */ 1113static void 1114dsl_dir_set_reservation_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) 1115{ 1116 dsl_dir_t *dd = arg1; --- 214 unchanged lines hidden --- | 1096 return (0); 1097} 1098 1099/* ARGSUSED */ 1100static void 1101dsl_dir_set_reservation_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) 1102{ 1103 dsl_dir_t *dd = arg1; --- 214 unchanged lines hidden --- |