Lines Matching refs:cp
288 decmpfs_cnode_init(decmpfs_cnode *cp)
290 memset(cp, 0, sizeof(*cp));
291 lck_rw_init(&cp->compressed_data_lock, decmpfs_lockgrp, NULL);
295 decmpfs_cnode_destroy(decmpfs_cnode *cp)
297 lck_rw_destroy(&cp->compressed_data_lock, decmpfs_lockgrp);
301 decmpfs_trylock_compressed_data(decmpfs_cnode *cp, int exclusive)
306 if (cp->lockowner == thread) {
308 cp->lockcount++;
311 if ((retval = lck_rw_try_lock_exclusive(&cp->compressed_data_lock))) {
312 cp->lockowner = thread;
313 cp->lockcount = 1;
316 if ((retval = lck_rw_try_lock_shared(&cp->compressed_data_lock))) {
317 cp->lockowner = (void *)-1;
324 decmpfs_lock_compressed_data(decmpfs_cnode *cp, int exclusive)
328 if (cp->lockowner == thread) {
330 cp->lockcount++;
332 lck_rw_lock_exclusive(&cp->compressed_data_lock);
333 cp->lockowner = thread;
334 cp->lockcount = 1;
336 lck_rw_lock_shared(&cp->compressed_data_lock);
337 cp->lockowner = (void *)-1;
342 decmpfs_unlock_compressed_data(decmpfs_cnode *cp, __unused int exclusive)
346 if (cp->lockowner == thread) {
348 if ((--cp->lockcount) > 0) {
352 cp->lockowner = NULL;
355 lck_rw_done(&cp->compressed_data_lock);
359 decmpfs_cnode_get_vnode_state(decmpfs_cnode *cp)
361 return cp->cmp_state;
365 decmpfs_cnode_set_vnode_state(decmpfs_cnode *cp, uint32_t state, int skiplock)
367 if (!skiplock) decmpfs_lock_compressed_data(cp, 1);
368 cp->cmp_state = state;
371 cp->cmp_type = 0;
373 if (!skiplock) decmpfs_unlock_compressed_data(cp, 1);
377 decmpfs_cnode_set_vnode_cmp_type(decmpfs_cnode *cp, uint32_t cmp_type, int skiplock)
379 if (!skiplock) decmpfs_lock_compressed_data(cp, 1);
380 cp->cmp_type = cmp_type;
381 if (!skiplock) decmpfs_unlock_compressed_data(cp, 1);
385 decmpfs_cnode_set_vnode_minimal_xattr(decmpfs_cnode *cp, int minimal_xattr, int skiplock)
387 if (!skiplock) decmpfs_lock_compressed_data(cp, 1);
388 cp->cmp_minimal_xattr = minimal_xattr;
389 if (!skiplock) decmpfs_unlock_compressed_data(cp, 1);
393 decmpfs_cnode_get_vnode_cached_size(decmpfs_cnode *cp)
395 return cp->uncompressed_size;
399 decmpfs_cnode_set_vnode_cached_size(decmpfs_cnode *cp, uint64_t size)
402 uint64_t old = cp->uncompressed_size;
403 if (OSCompareAndSwap64(old, size, (UInt64*)&cp->uncompressed_size)) {
412 decmpfs_cnode_get_decompression_flags(decmpfs_cnode *cp)
414 return cp->decompression_flags;
418 decmpfs_cnode_set_decompression_flags(decmpfs_cnode *cp, uint64_t flags)
421 uint64_t old = cp->decompression_flags;
422 if (OSCompareAndSwap64(old, flags, (UInt64*)&cp->decompression_flags)) {
433 decmpfs_fetch_compressed_header(vnode_t vp, decmpfs_cnode *cp, decmpfs_header **hdrOut, int returnInvalid)
449 if ((cp != NULL) &&
450 (cp->cmp_type != 0) &&
451 (cp->cmp_minimal_xattr != 0)) {
462 hdr->compression_type = cp->cmp_type;
463 hdr->uncompressed_size = decmpfs_cnode_get_vnode_cached_size(cp);
530 decmpfs_fast_get_state(decmpfs_cnode *cp)
537 int cmp_state = decmpfs_cnode_get_vnode_state(cp);
559 decmpfs_fast_file_is_compressed(decmpfs_cnode *cp)
561 int cmp_state = decmpfs_cnode_get_vnode_state(cp);
584 decmpfs_validate_compressed_file(vnode_t vp, decmpfs_cnode *cp)
589 errno_t err = decmpfs_fetch_compressed_header(vp, cp, &hdr, 0);
592 if (decmpfs_fast_get_state(cp) == FILE_IS_NOT_COMPRESSED) {
623 decmpfs_file_is_compressed(vnode_t vp, decmpfs_cnode *cp)
653 cmp_state = decmpfs_cnode_get_vnode_state(cp);
694 decmpfs_lock_compressed_data(cp, 1);
707 error = decmpfs_fetch_compressed_header(vp, cp, &hdr, 1);
734 decmpfs_lock_compressed_data(cp, 1);
738 decmpfs_cnode_set_vnode_cached_size(cp, hdr->uncompressed_size);
739 decmpfs_cnode_set_vnode_state(cp, ret, 1);
740 decmpfs_cnode_set_vnode_cmp_type(cp, hdr->compression_type, 1);
743 decmpfs_cnode_set_vnode_minimal_xattr(cp, 1, 1);
756 decmpfs_cnode_set_decompression_flags(cp, decompression_flags);
760 decmpfs_cnode_set_vnode_state(cp, ret, cnode_locked);
763 if (cnode_locked) decmpfs_unlock_compressed_data(cp, 1);
839 wait_for_decompress(decmpfs_cnode *cp)
844 state = decmpfs_fast_get_state(cp);
857 decmpfs_hides_rsrc(vfs_context_t ctx, decmpfs_cnode *cp)
870 if (!decmpfs_fast_file_is_compressed(cp))
878 decmpfs_hides_xattr(vfs_context_t ctx, decmpfs_cnode *cp, const char *xattr)
891 return decmpfs_hides_rsrc(ctx, cp);
892 if (!decmpfs_fast_file_is_compressed(cp))
986 decmpfs_fetch_uncompressed_data(vnode_t vp, decmpfs_cnode *cp, decmpfs_header *hdr, off_t offset, user_ssize_t size, int nvec, decmpfs_vector *vec, uint64_t *bytes_read)
1020 uint64_t decompression_flags = decmpfs_cnode_get_decompression_flags(cp);
1060 decmpfs_pagein_compressed(struct vnop_pagein_args *ap, int *is_compressed, decmpfs_cnode *cp)
1079 if(!decmpfs_trylock_compressed_data(cp, 0)) {
1089 err = decmpfs_fetch_compressed_header(vp, cp, &hdr, 0);
1126 if (decmpfs_fast_get_state(cp) == FILE_IS_CONVERTING) {
1135 err = decmpfs_fetch_uncompressed_data(vp, cp, hdr, uplPos, uplSize, 1, &vec, &did_read);
1139 int cmp_state = decmpfs_fast_get_state(cp);
1142 cmp_state = wait_for_decompress(cp);
1176 if (cmpdata_locked) decmpfs_unlock_compressed_data(cp, 0);
1184 decmpfs_read_compressed(struct vnop_read_args *ap, int *is_compressed, decmpfs_cnode *cp)
1209 decmpfs_lock_compressed_data(cp, 0); cmpdata_locked = 1;
1215 cachedSize = decmpfs_cnode_get_vnode_cached_size(cp);
1241 err = decmpfs_fetch_compressed_header(vp, cp, &hdr, 0);
1334 err = decmpfs_fetch_uncompressed_data(vp, cp, hdr, curUplPos, curUplSize, 1, &vec, &did_read);
1339 int cmp_state = decmpfs_fast_get_state(cp);
1342 cmp_state = wait_for_decompress(cp);
1404 if (cmpdata_locked) decmpfs_unlock_compressed_data(cp, 0);
1419 decmpfs_free_compressed_data(vnode_t vp, decmpfs_cnode *cp)
1427 int err = decmpfs_fetch_compressed_header(vp, cp, &hdr, 0);
1486 decmpfs_decompress_file(vnode_t vp, decmpfs_cnode *cp, off_t toSize, int truncate_okay, int skiplock)
1504 decmpfs_lock_compressed_data(cp, 1); cmpdata_locked = 1;
1508 old_state = decmpfs_fast_get_state(cp);
1521 (void)decmpfs_file_is_compressed(vp, cp);
1545 err = decmpfs_fetch_compressed_header(vp, cp, &hdr, 0);
1582 decmpfs_cnode_set_vnode_state(cp, FILE_IS_CONVERTING, 1);
1589 err = decmpfs_fetch_uncompressed_data(vp, cp, hdr, offset, vec.size, 1, &vec, &bytes_read);
1653 err = decmpfs_free_compressed_data(vp, cp);
1693 decmpfs_cnode_set_vnode_state(cp, new_state, 1);
1698 if (cmpdata_locked) decmpfs_unlock_compressed_data(cp, 1);