Print this page
NEX-3562 filename normalization doesn't work for removes (sync with upstream)
NEX-8972 Async-delete side-effect that may cause unmount EBUSY
Reviewed by: Alek Pinchuk <alek@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-8466 Failed to do 'pkg update' because of beadm failed to create BE, because of EBUSY in umount
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5108 make deletes interruptible on pool export
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-5036 case-insensitive matching is not working on casesensitivity=mixed, normalization=none FS
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-3562 filename normalization doesn't work for removes
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-4290 'insensitive' case sensitivity is broken
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-3762 Appliance crashes with a NULL pointer dereference during a zpool export when a zfs_vn_rele_taskq thread attempts to check a bogus rwlock from rw_write_held
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
6328 Fix cstyle errors in zfs codebase (fix studio)
6328 Fix cstyle errors in zfs codebase
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Jorgen Lundman <lundman@lundman.net>
Approved by: Robert Mustacchi <rm@joyent.com>
NEX-3329 libnsl: set_up_connection() over TCP does not adhere the specified timeout
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-3521 CLONE - Port NEX-3209 normalization=formD and casesensitivity=mixed behaves improperly, squashing case
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-2965 4.0.3-FP2: deferred deletes causing RSF import failure during fail-over of service
Reviewed by: Josef Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
SUP-780 zfs with casesensitivity=mixed and Unicode normalization doesn't normalize properly/fully


  35 #include <sys/vfs.h>
  36 #include <sys/vnode.h>
  37 #include <sys/file.h>
  38 #include <sys/mode.h>
  39 #include <sys/kmem.h>
  40 #include <sys/uio.h>
  41 #include <sys/pathname.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/errno.h>
  44 #include <sys/stat.h>
  45 #include <sys/unistd.h>
  46 #include <sys/sunddi.h>
  47 #include <sys/random.h>
  48 #include <sys/policy.h>
  49 #include <sys/zfs_dir.h>
  50 #include <sys/zfs_acl.h>
  51 #include <sys/fs/zfs.h>
  52 #include "fs/fs_subr.h"
  53 #include <sys/zap.h>
  54 #include <sys/dmu.h>

  55 #include <sys/atomic.h>
  56 #include <sys/zfs_ctldir.h>
  57 #include <sys/zfs_fuid.h>
  58 #include <sys/sa.h>
  59 #include <sys/zfs_sa.h>
  60 #include <sys/dnlc.h>
  61 #include <sys/extdirent.h>
  62 
  63 /*
  64  * zfs_match_find() is used by zfs_dirent_lock() to peform zap lookups
  65  * of names after deciding which is the appropriate lookup interface.
  66  */
  67 static int
  68 zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
  69     boolean_t update, int *deflags, pathname_t *rpnp, uint64_t *zoid)
  70 {
  71         int error;
  72 
  73         if (zfsvfs->z_norm) {
  74                 boolean_t conflict = B_FALSE;


 463  * Therefore it is remotely possible for some of the assertions
 464  * regarding the unlinked set below to fail due to i/o error.  On a
 465  * nondebug system, this will result in the space being leaked.
 466  */
 467 void
 468 zfs_unlinked_add(znode_t *zp, dmu_tx_t *tx)
 469 {
 470         zfsvfs_t *zfsvfs = zp->z_zfsvfs;
 471 
 472         ASSERT(zp->z_unlinked);
 473         ASSERT(zp->z_links == 0);
 474 
 475         VERIFY3U(0, ==,
 476             zap_add_int(zfsvfs->z_os, zfsvfs->z_unlinkedobj, zp->z_id, tx));
 477 }
 478 
 479 /*
 480  * Clean up any znodes that had no links when we either crashed or
 481  * (force) umounted the file system.
 482  */
 483 void
 484 zfs_unlinked_drain(zfsvfs_t *zfsvfs)
 485 {
 486         zap_cursor_t    zc;
 487         zap_attribute_t zap;
 488         dmu_object_info_t doi;
 489         znode_t         *zp;
 490         int             error;
 491 

 492         /*
 493          * Interate over the contents of the unlinked set.
 494          */
 495         for (zap_cursor_init(&zc, zfsvfs->z_os, zfsvfs->z_unlinkedobj);
 496             zap_cursor_retrieve(&zc, &zap) == 0;


 497             zap_cursor_advance(&zc)) {
 498 
 499                 /*
 500                  * See what kind of object we have in list
 501                  */
 502 
 503                 error = dmu_object_info(zfsvfs->z_os,
 504                     zap.za_first_integer, &doi);
 505                 if (error != 0)
 506                         continue;
 507 
 508                 ASSERT((doi.doi_type == DMU_OT_PLAIN_FILE_CONTENTS) ||
 509                     (doi.doi_type == DMU_OT_DIRECTORY_CONTENTS));
 510                 /*
 511                  * We need to re-mark these list entries for deletion,
 512                  * so we pull them back into core and set zp->z_unlinked.
 513                  */
 514                 error = zfs_zget(zfsvfs, zap.za_first_integer, &zp);
 515 
 516                 /*
 517                  * We may pick up znodes that are already marked for deletion.
 518                  * This could happen during the purge of an extended attribute
 519                  * directory.  All we need to do is skip over them, since they
 520                  * are already in the system marked z_unlinked.
 521                  */
 522                 if (error != 0)
 523                         continue;
 524 
 525                 zp->z_unlinked = B_TRUE;
 526                 VN_RELE(ZTOV(zp));


 527         }
 528         zap_cursor_fini(&zc);





 529 }
 530 









































 531 /*
 532  * Delete the entire contents of a directory.  Return a count
 533  * of the number of entries that could not be deleted. If we encounter
 534  * an error, return a count of at least one so that the directory stays
 535  * in the unlinked set.
 536  *
 537  * NOTE: this function assumes that the directory is inactive,
 538  *      so there is no need to lock its entries before deletion.
 539  *      Also, it assumes the directory contents is *only* regular
 540  *      files.
 541  */
 542 static int
 543 zfs_purgedir(znode_t *dzp)
 544 {
 545         zap_cursor_t    zc;
 546         zap_attribute_t zap;
 547         znode_t         *xzp;
 548         dmu_tx_t        *tx;
 549         zfsvfs_t        *zfsvfs = dzp->z_zfsvfs;
 550         zfs_dirlock_t   dl;




  35 #include <sys/vfs.h>
  36 #include <sys/vnode.h>
  37 #include <sys/file.h>
  38 #include <sys/mode.h>
  39 #include <sys/kmem.h>
  40 #include <sys/uio.h>
  41 #include <sys/pathname.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/errno.h>
  44 #include <sys/stat.h>
  45 #include <sys/unistd.h>
  46 #include <sys/sunddi.h>
  47 #include <sys/random.h>
  48 #include <sys/policy.h>
  49 #include <sys/zfs_dir.h>
  50 #include <sys/zfs_acl.h>
  51 #include <sys/fs/zfs.h>
  52 #include "fs/fs_subr.h"
  53 #include <sys/zap.h>
  54 #include <sys/dmu.h>
  55 #include <sys/dmu_objset.h>
  56 #include <sys/atomic.h>
  57 #include <sys/zfs_ctldir.h>
  58 #include <sys/zfs_fuid.h>
  59 #include <sys/sa.h>
  60 #include <sys/zfs_sa.h>
  61 #include <sys/dnlc.h>
  62 #include <sys/extdirent.h>
  63 
  64 /*
  65  * zfs_match_find() is used by zfs_dirent_lock() to peform zap lookups
  66  * of names after deciding which is the appropriate lookup interface.
  67  */
  68 static int
  69 zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
  70     boolean_t update, int *deflags, pathname_t *rpnp, uint64_t *zoid)
  71 {
  72         int error;
  73 
  74         if (zfsvfs->z_norm) {
  75                 boolean_t conflict = B_FALSE;


 464  * Therefore it is remotely possible for some of the assertions
 465  * regarding the unlinked set below to fail due to i/o error.  On a
 466  * nondebug system, this will result in the space being leaked.
 467  */
 468 void
 469 zfs_unlinked_add(znode_t *zp, dmu_tx_t *tx)
 470 {
 471         zfsvfs_t *zfsvfs = zp->z_zfsvfs;
 472 
 473         ASSERT(zp->z_unlinked);
 474         ASSERT(zp->z_links == 0);
 475 
 476         VERIFY3U(0, ==,
 477             zap_add_int(zfsvfs->z_os, zfsvfs->z_unlinkedobj, zp->z_id, tx));
 478 }
 479 
 480 /*
 481  * Clean up any znodes that had no links when we either crashed or
 482  * (force) umounted the file system.
 483  */
 484 static void
 485 zfs_unlinked_drain_impl(zfsvfs_t *zfsvfs)
 486 {
 487         zap_cursor_t    zc;
 488         zap_attribute_t zap;
 489         dmu_object_info_t doi;
 490         znode_t         *zp;
 491         int             error;
 492 
 493         ASSERT(zfsvfs->z_drain_state != ZFS_DRAIN_SHUTDOWN);
 494         /*
 495          * Interate over the contents of the unlinked set.
 496          */
 497         for (zap_cursor_init(&zc, zfsvfs->z_os, zfsvfs->z_unlinkedobj);
 498             zap_cursor_retrieve(&zc, &zap) == 0 &&
 499             /* Only checking for a shutdown request, so no locking reqd. */
 500             zfsvfs->z_drain_state == ZFS_DRAIN_RUNNING;
 501             zap_cursor_advance(&zc)) {
 502 
 503                 /*
 504                  * See what kind of object we have in list
 505                  */
 506 
 507                 error = dmu_object_info(zfsvfs->z_os,
 508                     zap.za_first_integer, &doi);
 509                 if (error != 0)
 510                         continue;
 511 
 512                 ASSERT((doi.doi_type == DMU_OT_PLAIN_FILE_CONTENTS) ||
 513                     (doi.doi_type == DMU_OT_DIRECTORY_CONTENTS));
 514                 /*
 515                  * We need to re-mark these list entries for deletion,
 516                  * so we pull them back into core and set zp->z_unlinked.
 517                  */
 518                 error = zfs_zget(zfsvfs, zap.za_first_integer, &zp);
 519 
 520                 /*
 521                  * We may pick up znodes that are already marked for deletion.
 522                  * This could happen during the purge of an extended attribute
 523                  * directory.  All we need to do is skip over them, since they
 524                  * are already in the system marked z_unlinked.
 525                  */
 526                 if (error != 0)
 527                         continue;
 528 
 529                 zp->z_unlinked = B_TRUE;
 530                 VN_RELE(ZTOV(zp));
 531 
 532                 ASSERT(!zfsvfs->z_unmounted);
 533         }
 534         zap_cursor_fini(&zc);
 535 
 536         mutex_enter(&zfsvfs->z_drain_lock);
 537         zfsvfs->z_drain_state = ZFS_DRAIN_SHUTDOWN;
 538         cv_broadcast(&zfsvfs->z_drain_cv);
 539         mutex_exit(&zfsvfs->z_drain_lock);
 540 }
 541 
 542 /*
 543  * Setup required hold. After that tries to dispatch
 544  * async unlinked drain logic. Otherwise executes
 545  * the logic synchronously.
 546  */
 547 void
 548 zfs_unlinked_drain(zfsvfs_t *zfsvfs)
 549 {
 550         ASSERT(!zfsvfs->z_unmounted);
 551 
 552         mutex_enter(&zfsvfs->z_drain_lock);
 553         ASSERT(zfsvfs->z_drain_state == ZFS_DRAIN_SHUTDOWN);
 554         zfsvfs->z_drain_state = ZFS_DRAIN_RUNNING;
 555         mutex_exit(&zfsvfs->z_drain_lock);
 556 
 557         if (taskq_dispatch(dsl_pool_vnrele_taskq(
 558             spa_get_dsl(zfsvfs->z_os->os_spa)),
 559             (void (*)(void *))zfs_unlinked_drain_impl, zfsvfs,
 560             TQ_NOSLEEP) == NULL) {
 561                 cmn_err(CE_WARN, "async zfs_unlinked_drain dispatch failed");
 562                 zfs_unlinked_drain_impl(zfsvfs);
 563         }
 564 }
 565 
 566 /*
 567  * Stops an asynchronous zfs_unlinked_drain. This must be called prior to
 568  * destroying the zfsvfs_t, as the drain doesn't hold the z_teardown_lock.
 569  */
 570 void
 571 zfs_unlinked_drain_stop_wait(zfsvfs_t *zfsvfs)
 572 {
 573         ASSERT(!zfsvfs->z_unmounted);
 574 
 575         mutex_enter(&zfsvfs->z_drain_lock);
 576         while (zfsvfs->z_drain_state != ZFS_DRAIN_SHUTDOWN) {
 577                 zfsvfs->z_drain_state = ZFS_DRAIN_SHUTDOWN_REQ;
 578                 cv_wait(&zfsvfs->z_drain_cv, &zfsvfs->z_drain_lock);
 579         }
 580         mutex_exit(&zfsvfs->z_drain_lock);
 581 }
 582 
 583 /*
 584  * Delete the entire contents of a directory.  Return a count
 585  * of the number of entries that could not be deleted. If we encounter
 586  * an error, return a count of at least one so that the directory stays
 587  * in the unlinked set.
 588  *
 589  * NOTE: this function assumes that the directory is inactive,
 590  *      so there is no need to lock its entries before deletion.
 591  *      Also, it assumes the directory contents is *only* regular
 592  *      files.
 593  */
 594 static int
 595 zfs_purgedir(znode_t *dzp)
 596 {
 597         zap_cursor_t    zc;
 598         zap_attribute_t zap;
 599         znode_t         *xzp;
 600         dmu_tx_t        *tx;
 601         zfsvfs_t        *zfsvfs = dzp->z_zfsvfs;
 602         zfs_dirlock_t   dl;