Print this page
3741 zfs needs better comments
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>


 392     dmu_tx_t *tx);
 393 
 394 /*
 395  * Decide how to write a block: checksum, compression, number of copies, etc.
 396  */
 397 #define WP_NOFILL       0x1
 398 #define WP_DMU_SYNC     0x2
 399 #define WP_SPILL        0x4
 400 
 401 void dmu_write_policy(objset_t *os, struct dnode *dn, int level, int wp,
 402     struct zio_prop *zp);
 403 /*
 404  * The bonus data is accessed more or less like a regular buffer.
 405  * You must dmu_bonus_hold() to get the buffer, which will give you a
 406  * dmu_buf_t with db_offset==-1ULL, and db_size = the size of the bonus
 407  * data.  As with any normal buffer, you must call dmu_buf_read() to
 408  * read db_data, dmu_buf_will_dirty() before modifying it, and the
 409  * object must be held in an assigned transaction before calling
 410  * dmu_buf_will_dirty.  You may use dmu_buf_set_user() on the bonus
 411  * buffer as well.  You must release your hold with dmu_buf_rele().


 412  */
 413 int dmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **);
 414 int dmu_bonus_max(void);
 415 int dmu_set_bonus(dmu_buf_t *, int, dmu_tx_t *);
 416 int dmu_set_bonustype(dmu_buf_t *, dmu_object_type_t, dmu_tx_t *);
 417 dmu_object_type_t dmu_get_bonustype(dmu_buf_t *);
 418 int dmu_rm_spill(objset_t *, uint64_t, dmu_tx_t *);
 419 
 420 /*
 421  * Special spill buffer support used by "SA" framework
 422  */
 423 
 424 int dmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp);
 425 int dmu_spill_hold_by_dnode(struct dnode *dn, uint32_t flags,
 426     void *tag, dmu_buf_t **dbp);
 427 int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp);
 428 
 429 /*
 430  * Obtain the DMU buffer from the specified object which contains the
 431  * specified offset.  dmu_buf_hold() puts a "hold" on the buffer, so


 647         boolean_t               ot_metadata;
 648         char                    *ot_name;
 649 } dmu_object_type_info_t;
 650 
 651 typedef struct dmu_object_byteswap_info {
 652         arc_byteswap_func_t     *ob_func;
 653         char                    *ob_name;
 654 } dmu_object_byteswap_info_t;
 655 
 656 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES];
 657 extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
 658 
 659 /*
 660  * Get information on a DMU object.
 661  *
 662  * Return 0 on success or ENOENT if object is not allocated.
 663  *
 664  * If doi is NULL, just indicates whether the object exists.
 665  */
 666 int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi);

 667 void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi);

 668 void dmu_object_info_from_db(dmu_buf_t *db, dmu_object_info_t *doi);




 669 void dmu_object_size_from_db(dmu_buf_t *db, uint32_t *blksize,
 670     u_longlong_t *nblk512);
 671 
 672 typedef struct dmu_objset_stats {
 673         uint64_t dds_num_clones; /* number of clones of this */
 674         uint64_t dds_creation_txg;
 675         uint64_t dds_guid;
 676         dmu_objset_type_t dds_type;
 677         uint8_t dds_is_snapshot;
 678         uint8_t dds_inconsistent;
 679         char dds_origin[MAXNAMELEN];
 680 } dmu_objset_stats_t;
 681 
 682 /*
 683  * Get stats on a dataset.
 684  */
 685 void dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat);
 686 
 687 /*
 688  * Add entries to the nvlist for all the objset's properties.  See




 392     dmu_tx_t *tx);
 393 
 394 /*
 395  * Decide how to write a block: checksum, compression, number of copies, etc.
 396  */
 397 #define WP_NOFILL       0x1
 398 #define WP_DMU_SYNC     0x2
 399 #define WP_SPILL        0x4
 400 
 401 void dmu_write_policy(objset_t *os, struct dnode *dn, int level, int wp,
 402     struct zio_prop *zp);
 403 /*
 404  * The bonus data is accessed more or less like a regular buffer.
 405  * You must dmu_bonus_hold() to get the buffer, which will give you a
 406  * dmu_buf_t with db_offset==-1ULL, and db_size = the size of the bonus
 407  * data.  As with any normal buffer, you must call dmu_buf_read() to
 408  * read db_data, dmu_buf_will_dirty() before modifying it, and the
 409  * object must be held in an assigned transaction before calling
 410  * dmu_buf_will_dirty.  You may use dmu_buf_set_user() on the bonus
 411  * buffer as well.  You must release your hold with dmu_buf_rele().
 412  *
 413  * Returns ENOENT, EIO, or 0.
 414  */
 415 int dmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **);
 416 int dmu_bonus_max(void);
 417 int dmu_set_bonus(dmu_buf_t *, int, dmu_tx_t *);
 418 int dmu_set_bonustype(dmu_buf_t *, dmu_object_type_t, dmu_tx_t *);
 419 dmu_object_type_t dmu_get_bonustype(dmu_buf_t *);
 420 int dmu_rm_spill(objset_t *, uint64_t, dmu_tx_t *);
 421 
 422 /*
 423  * Special spill buffer support used by "SA" framework
 424  */
 425 
 426 int dmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp);
 427 int dmu_spill_hold_by_dnode(struct dnode *dn, uint32_t flags,
 428     void *tag, dmu_buf_t **dbp);
 429 int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp);
 430 
 431 /*
 432  * Obtain the DMU buffer from the specified object which contains the
 433  * specified offset.  dmu_buf_hold() puts a "hold" on the buffer, so


 649         boolean_t               ot_metadata;
 650         char                    *ot_name;
 651 } dmu_object_type_info_t;
 652 
 653 typedef struct dmu_object_byteswap_info {
 654         arc_byteswap_func_t     *ob_func;
 655         char                    *ob_name;
 656 } dmu_object_byteswap_info_t;
 657 
 658 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES];
 659 extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
 660 
 661 /*
 662  * Get information on a DMU object.
 663  *
 664  * Return 0 on success or ENOENT if object is not allocated.
 665  *
 666  * If doi is NULL, just indicates whether the object exists.
 667  */
 668 int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi);
 669 /* Like dmu_object_info, but faster if you have a held dnode in hand. */
 670 void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi);
 671 /* Like dmu_object_info, but faster if you have a held dbuf in hand. */
 672 void dmu_object_info_from_db(dmu_buf_t *db, dmu_object_info_t *doi);
 673 /*
 674  * Like dmu_object_info_from_db, but faster still when you only care about
 675  * the size.  This is specifically optimized for zfs_getattr().
 676  */
 677 void dmu_object_size_from_db(dmu_buf_t *db, uint32_t *blksize,
 678     u_longlong_t *nblk512);
 679 
 680 typedef struct dmu_objset_stats {
 681         uint64_t dds_num_clones; /* number of clones of this */
 682         uint64_t dds_creation_txg;
 683         uint64_t dds_guid;
 684         dmu_objset_type_t dds_type;
 685         uint8_t dds_is_snapshot;
 686         uint8_t dds_inconsistent;
 687         char dds_origin[MAXNAMELEN];
 688 } dmu_objset_stats_t;
 689 
 690 /*
 691  * Get stats on a dataset.
 692  */
 693 void dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat);
 694 
 695 /*
 696  * Add entries to the nvlist for all the objset's properties.  See