MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zfs_rmnode

Function zfs_rmnode

freebsd/contrib/openzfs/module/os/linux/zfs/zfs_dir.c:645–772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645void
646zfs_rmnode(znode_t *zp)
647{
648 zfsvfs_t *zfsvfs = ZTOZSB(zp);
649 objset_t *os = zfsvfs->z_os;
650 znode_t *xzp = NULL;
651 dmu_tx_t *tx;
652 uint64_t acl_obj;
653 uint64_t xattr_obj;
654 uint64_t links;
655 int error;
656
657 ASSERT(ZTOI(zp)->i_nlink == 0);
658 ASSERT(atomic_read(&ZTOI(zp)->i_count) == 0);
659
660 /*
661 * If this is an attribute directory, purge its contents.
662 */
663 if (S_ISDIR(ZTOI(zp)->i_mode) && (zp->z_pflags & ZFS_XATTR)) {
664 if (zfs_purgedir(zp) != 0) {
665 /*
666 * Not enough space to delete some xattrs.
667 * Leave it in the unlinked set.
668 */
669 zfs_znode_dmu_fini(zp);
670
671 return;
672 }
673 }
674
675 /*
676 * Free up all the data in the file. We don't do this for directories
677 * because we need truncate and remove to be in the same tx, like in
678 * zfs_znode_delete(). Otherwise, if we crash here we'll end up with
679 * an inconsistent truncated zap object in the delete queue. Note a
680 * truncated file is harmless since it only contains user data.
681 */
682 if (S_ISREG(ZTOI(zp)->i_mode)) {
683 error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END);
684 if (error) {
685 /*
686 * Not enough space or we were interrupted by unmount.
687 * Leave the file in the unlinked set.
688 */
689 zfs_znode_dmu_fini(zp);
690 return;
691 }
692 }
693
694 /*
695 * If the file has extended attributes, we're going to unlink
696 * the xattr dir.
697 */
698 error = sa_lookup(zp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs),
699 &xattr_obj, sizeof (xattr_obj));
700 if (error == 0 && xattr_obj) {
701 error = zfs_zget(zfsvfs, xattr_obj, &xzp);
702 ASSERT(error == 0);

Callers 1

zfs_zinactiveFunction · 0.70

Calls 15

atomic_readFunction · 0.85
dmu_free_long_rangeFunction · 0.85
sa_lookupFunction · 0.85
dmu_tx_createFunction · 0.85
dmu_tx_hold_freeFunction · 0.85
dmu_tx_hold_zapFunction · 0.85
dmu_tx_hold_saFunction · 0.85
zfs_sa_upgrade_txholdsFunction · 0.85
dmu_tx_assignFunction · 0.85
dmu_tx_abortFunction · 0.85
mutex_enterFunction · 0.85
sa_updateFunction · 0.85

Tested by

no test coverage detected