230 rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \
231 if ((zfsvfs)->z_unmounted) { \
232 ZFS_EXIT(zfsvfs); \
233 return (EIO); \
234 } \
235 }
236
237 /* Must be called before exiting the vop */
238 #define ZFS_EXIT(zfsvfs) rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG)
239
240 /* Verifies the znode is valid */
241 #define ZFS_VERIFY_ZP(zp) \
242 if ((zp)->z_sa_hdl == NULL) { \
243 ZFS_EXIT((zp)->z_zfsvfs); \
244 return (EIO); \
245 } \
246
247 /*
248 * Macros for dealing with dmu_buf_hold
249 */
250 #define ZFS_OBJ_HASH(obj_num) ((obj_num) & (ZFS_OBJ_MTX_SZ - 1))
251 #define ZFS_OBJ_MUTEX(zfsvfs, obj_num) \
252 (&(zfsvfs)->z_hold_mtx[ZFS_OBJ_HASH(obj_num)])
253 #define ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num) \
254 mutex_enter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
255 #define ZFS_OBJ_HOLD_TRYENTER(zfsvfs, obj_num) \
256 mutex_tryenter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
257 #define ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num) \
258 mutex_exit(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
259
260 /* Encode ZFS stored time values from a struct timespec */
261 #define ZFS_TIME_ENCODE(tp, stmp) \
262 { \
263 (stmp)[0] = (uint64_t)(tp)->tv_sec; \
264 (stmp)[1] = (uint64_t)(tp)->tv_nsec; \
265 }
266
267 /* Decode ZFS stored time values to a struct timespec */
268 #define ZFS_TIME_DECODE(tp, stmp) \
269 { \
270 (tp)->tv_sec = (time_t)(stmp)[0]; \
271 (tp)->tv_nsec = (long)(stmp)[1]; \
272 }
|
230 rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \
231 if ((zfsvfs)->z_unmounted) { \
232 ZFS_EXIT(zfsvfs); \
233 return (EIO); \
234 } \
235 }
236
237 /* Must be called before exiting the vop */
238 #define ZFS_EXIT(zfsvfs) rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG)
239
240 /* Verifies the znode is valid */
241 #define ZFS_VERIFY_ZP(zp) \
242 if ((zp)->z_sa_hdl == NULL) { \
243 ZFS_EXIT((zp)->z_zfsvfs); \
244 return (EIO); \
245 } \
246
247 /*
248 * Macros for dealing with dmu_buf_hold
249 */
250 #define ZFS_OBJ_HASH(obj_num, table_sz) ((obj_num) & (table_sz - 1))
251 #define ZFS_OBJ_MUTEX(zfsvfs, obj_num) \
252 (&(zfsvfs)->z_hold_mtx[ZFS_OBJ_HASH(obj_num, (zfsvfs)->z_hold_mtx_sz)])
253 #define ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num) \
254 mutex_enter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
255 #define ZFS_OBJ_HOLD_TRYENTER(zfsvfs, obj_num) \
256 mutex_tryenter(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
257 #define ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num) \
258 mutex_exit(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
259
260 /* Encode ZFS stored time values from a struct timespec */
261 #define ZFS_TIME_ENCODE(tp, stmp) \
262 { \
263 (stmp)[0] = (uint64_t)(tp)->tv_sec; \
264 (stmp)[1] = (uint64_t)(tp)->tv_nsec; \
265 }
266
267 /* Decode ZFS stored time values to a struct timespec */
268 #define ZFS_TIME_DECODE(tp, stmp) \
269 { \
270 (tp)->tv_sec = (time_t)(stmp)[0]; \
271 (tp)->tv_nsec = (long)(stmp)[1]; \
272 }
|