~davewalker/ubuntu/natty/ocfs2-tools/bug_363877

« back to all changes in this revision

Viewing changes to include/ocfs2/ocfs2.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-01-14 12:46:49 UTC
  • mfrom: (1.1.10 upstream) (0.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110114124649-vbe5qz211f3zxwuf
Tags: 1.6.3-1ubuntu1
* Merge from debian unstable (LP: #703008).  Remaining changes:
  - Fix configure tests for ld --as-needed.
  - Fix build failure with ld --no-add-needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#include <ocfs2-kernel/kernel-list.h>
52
52
#include <ocfs2-kernel/sparse_endian_types.h>
53
53
#include <ocfs2-kernel/ocfs2_fs.h>
 
54
#include <ocfs2-kernel/quota_tree.h>
54
55
#include <o2dlm/o2dlm.h>
55
56
#include <o2cb/o2cb.h>
56
57
#include <ocfs2/ocfs2_err.h>
57
58
#include <ocfs2/jbd2.h>
58
59
#include <ocfs2-kernel/ocfs2_lockid.h>
 
60
#include <ocfs2-kernel/ocfs2_ioctl.h>
59
61
 
60
62
#define OCFS2_LIB_FEATURE_INCOMPAT_SUPP         (OCFS2_FEATURE_INCOMPAT_SUPP | \
61
63
                                                 OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV | \
87
89
#define OCFS2_FLAG_HEARTBEAT_DEV_OK     0x40
88
90
#define OCFS2_FLAG_STRICT_COMPAT_CHECK  0x80
89
91
#define OCFS2_FLAG_IMAGE_FILE         0x0100
 
92
#define OCFS2_FLAG_NO_ECC_CHECKS      0x0200    /* Do not validate metaecc
 
93
                                                 * information on block
 
94
                                                 * reads. */
 
95
 
90
96
 
91
97
/* Return flags for the directory iterator functions */
92
98
#define OCFS2_DIRENT_CHANGED    0x01
126
132
#define OCFS2_CHB_WAITING       2
127
133
#define OCFS2_CHB_COMPLETE      3
128
134
 
 
135
/* Flags for global quotafile info */
 
136
#define OCFS2_QF_INFO_DIRTY 1
 
137
#define OCFS2_QF_INFO_LOADED 2
 
138
 
129
139
typedef void (*ocfs2_chb_notify)(int state, char *progress, void *data);
130
140
 
131
141
typedef struct _ocfs2_filesys ocfs2_filesys;
132
142
typedef struct _ocfs2_cached_inode ocfs2_cached_inode;
 
143
typedef struct _ocfs2_cached_dquot ocfs2_cached_dquot;
133
144
typedef struct _io_channel io_channel;
134
145
typedef struct _ocfs2_inode_scan ocfs2_inode_scan;
135
146
typedef struct _ocfs2_dir_scan ocfs2_dir_scan;
136
147
typedef struct _ocfs2_bitmap ocfs2_bitmap;
137
148
typedef struct _ocfs2_devices ocfs2_devices;
138
149
 
 
150
#define MAXQUOTAS 2
 
151
#define USRQUOTA 0
 
152
#define GRPQUOTA 1
 
153
 
 
154
#define OCFS2_DEF_BLOCK_GRACE 604800 /* 1 week */
 
155
#define OCFS2_DEF_INODE_GRACE 604800 /* 1 week */
 
156
#define OCFS2_DEF_QUOTA_SYNC 10000   /* 10 seconds */
 
157
 
 
158
struct _ocfs2_quota_info {
 
159
        ocfs2_cached_inode *qi_inode;
 
160
        int flags;
 
161
        struct ocfs2_global_disk_dqinfo qi_info;
 
162
};
 
163
 
 
164
typedef struct _ocfs2_quota_info ocfs2_quota_info;
 
165
 
139
166
struct _ocfs2_filesys {
140
167
        char *fs_devname;
141
168
        uint32_t fs_flags;
162
189
        struct o2dlm_ctxt *fs_dlm_ctxt;
163
190
        struct ocfs2_image_state *ost;
164
191
 
 
192
        ocfs2_quota_info qinfo[MAXQUOTAS];
 
193
 
165
194
        /* Reserved for the use of the calling application. */
166
195
        void *fs_private;
167
196
};
173
202
        ocfs2_bitmap *ci_chains;
174
203
};
175
204
 
 
205
typedef unsigned int qid_t;
 
206
 
 
207
struct _ocfs2_cached_dquot {
 
208
        loff_t d_off;   /* Offset of structure in the file */
 
209
        struct _ocfs2_cached_dquot *d_next;     /* Next entry in hashchain */
 
210
        struct _ocfs2_cached_dquot **d_pprev;   /* Previous pointer in hashchain */
 
211
        struct ocfs2_global_disk_dqblk d_ddquot;        /* Quota entry */
 
212
};
 
213
 
176
214
struct ocfs2_slot_data {
177
215
        int             sd_valid;
178
216
        unsigned int    sd_node_num;
207
245
        uint32_t opt_ro_compat;
208
246
};
209
247
 
 
248
enum ocfs2_mkfs_types {
 
249
        OCFS2_MKFSTYPE_DEFAULT,
 
250
        OCFS2_MKFSTYPE_DATAFILES,
 
251
        OCFS2_MKFSTYPE_MAIL,
 
252
        OCFS2_MKFSTYPE_VMSTORE,
 
253
};
 
254
 
 
255
struct _ocfs2_quota_hash {
 
256
        int alloc_entries;
 
257
        int used_entries;
 
258
        ocfs2_cached_dquot **hash;
 
259
};
 
260
 
 
261
struct ocfs2_dx_hinfo {
 
262
        uint32_t major_hash;
 
263
        uint32_t minor_hash;
 
264
};
 
265
 
 
266
struct ocfs2_dir_lookup_result {
 
267
        struct ocfs2_dx_hinfo       dl_hinfo;         /* name hash results */
 
268
        char *                      dl_leaf;          /* unindexed block buffer */
 
269
        uint64_t                    dl_leaf_blkno;    /* blk number of dl_leaf */
 
270
        struct ocfs2_dir_entry *    dl_entry;         /* dirent pointed into dl_leaf */
 
271
        struct ocfs2_dx_leaf *      dl_dx_leaf;       /* indexed block buffer */
 
272
        uint64_t                    dl_dx_leaf_blkno; /* blk number of dl_dx_leaf */
 
273
        struct ocfs2_dx_entry *     dl_dx_entry;      /* indexed entry pointed to dl_dx_leaf */
 
274
        int                         dl_dx_entry_idx;  /* index of dl_dx_entry in entries list */
 
275
};
 
276
 
 
277
typedef struct _ocfs2_quota_hash ocfs2_quota_hash;
 
278
 
210
279
errcode_t ocfs2_malloc(unsigned long size, void *ptr);
211
280
errcode_t ocfs2_malloc0(unsigned long size, void *ptr);
212
281
errcode_t ocfs2_free(void *ptr);
249
318
errcode_t io_init_cache(io_channel *channel, size_t nr_blocks);
250
319
void io_set_nocache(io_channel *channel, bool nocache);
251
320
errcode_t io_init_cache_size(io_channel *channel, size_t bytes);
 
321
errcode_t io_share_cache(io_channel *from, io_channel *to);
252
322
errcode_t io_mlock_cache(io_channel *channel);
253
323
void io_destroy_cache(io_channel *channel);
254
324
 
282
352
errcode_t ocfs2_write_inode(ocfs2_filesys *fs, uint64_t blkno,
283
353
                            char *inode_buf);
284
354
errcode_t ocfs2_check_directory(ocfs2_filesys *fs, uint64_t dir);
285
 
 
 
355
int ocfs2_check_dir_entry(ocfs2_filesys *fs, struct ocfs2_dir_entry *de,
 
356
                                char *dir_buf, unsigned int offset);
286
357
errcode_t ocfs2_read_cached_inode(ocfs2_filesys *fs, uint64_t blkno,
287
358
                                  ocfs2_cached_inode **ret_ci);
288
359
errcode_t ocfs2_write_cached_inode(ocfs2_filesys *fs,
289
360
                                   ocfs2_cached_inode *cinode);
290
361
errcode_t ocfs2_free_cached_inode(ocfs2_filesys *fs,
291
362
                                  ocfs2_cached_inode *cinode);
 
363
errcode_t ocfs2_refresh_cached_inode(ocfs2_filesys *fs,
 
364
                                     ocfs2_cached_inode *cinode);
292
365
 
293
366
/*
294
367
 * obj is the object containing the extent list.  eg, if you are swapping
311
384
                             uint32_t *p_cluster,
312
385
                             uint32_t *num_clusters,
313
386
                             uint16_t *extent_flags);
 
387
errcode_t ocfs2_xattr_get_clusters(ocfs2_filesys *fs,
 
388
                                   struct ocfs2_extent_list *el,
 
389
                                   uint64_t el_blkno,
 
390
                                   char *el_blk,
 
391
                                   uint32_t v_cluster,
 
392
                                   uint32_t *p_cluster,
 
393
                                   uint32_t *num_clusters,
 
394
                                   uint16_t *extent_flags);
314
395
int ocfs2_find_leaf(ocfs2_filesys *fs, struct ocfs2_dinode *di,
315
396
                    uint32_t cpos, char **leaf_buf);
316
397
int ocfs2_search_extent_list(struct ocfs2_extent_list *el, uint32_t v_cluster);
341
422
                                          char *eb_buf);
342
423
errcode_t ocfs2_write_extent_block(ocfs2_filesys *fs, uint64_t blkno,
343
424
                                   char *eb_buf);
 
425
void ocfs2_swap_refcount_list_to_cpu(ocfs2_filesys *fs, void *obj,
 
426
                                     struct ocfs2_refcount_list *rl);
 
427
void ocfs2_swap_refcount_list_from_cpu(ocfs2_filesys *fs, void *obj,
 
428
                                       struct ocfs2_refcount_list *rl);
 
429
void ocfs2_swap_refcount_block_to_cpu(ocfs2_filesys *fs,
 
430
                                      struct ocfs2_refcount_block *rb);
 
431
void ocfs2_swap_refcount_block_from_cpu(ocfs2_filesys *fs,
 
432
                                        struct ocfs2_refcount_block *rb);
 
433
errcode_t ocfs2_read_refcount_block(ocfs2_filesys *fs, uint64_t blkno,
 
434
                                    char *eb_buf);
 
435
errcode_t ocfs2_read_refcount_block_nocheck(ocfs2_filesys *fs, uint64_t blkno,
 
436
                                            char *eb_buf);
 
437
errcode_t ocfs2_write_refcount_block(ocfs2_filesys *fs, uint64_t blkno,
 
438
                                     char *rb_buf);
 
439
errcode_t ocfs2_delete_refcount_block(ocfs2_filesys *fs, uint64_t blkno);
 
440
errcode_t ocfs2_new_refcount_block(ocfs2_filesys *fs, uint64_t *blkno,
 
441
                                   uint64_t root_blkno, uint32_t rf_generation);
 
442
errcode_t ocfs2_increase_refcount(ocfs2_filesys *fs, uint64_t ino,
 
443
                                  uint64_t cpos, uint32_t len);
 
444
errcode_t ocfs2_decrease_refcount(ocfs2_filesys *fs,
 
445
                                  uint64_t ino, uint32_t cpos,
 
446
                                  uint32_t len, int delete);
 
447
errcode_t ocfs2_refcount_cow(ocfs2_cached_inode *cinode,
 
448
                             uint32_t cpos, uint32_t write_len,
 
449
                             uint32_t max_cpos);
 
450
errcode_t ocfs2_refcount_cow_xattr(ocfs2_cached_inode *ci,
 
451
                                   char *xe_buf,
 
452
                                   uint64_t xe_blkno,
 
453
                                   char *value_buf,
 
454
                                   uint64_t value_blkno,
 
455
                                   struct ocfs2_xattr_value_root *xv,
 
456
                                   uint32_t cpos, uint32_t write_len);
 
457
errcode_t ocfs2_change_refcount_flag(ocfs2_filesys *fs, uint64_t i_blkno,
 
458
                                     uint32_t v_cpos, uint32_t clusters,
 
459
                                     uint64_t p_cpos,
 
460
                                     int new_flags, int clear_flags);
 
461
errcode_t ocfs2_refcount_tree_get_rec(ocfs2_filesys *fs,
 
462
                                      struct ocfs2_refcount_block *rb,
 
463
                                      uint32_t phys_cpos,
 
464
                                      uint64_t *p_blkno,
 
465
                                      uint32_t *e_cpos,
 
466
                                      uint32_t *num_clusters);
 
467
errcode_t ocfs2_refcount_punch_hole(ocfs2_filesys *fs, uint64_t rf_blkno,
 
468
                                    uint64_t p_start, uint32_t len);
 
469
errcode_t ocfs2_change_refcount(ocfs2_filesys *fs, uint64_t rf_blkno,
 
470
                                uint64_t p_start, uint32_t len,
 
471
                                uint32_t refcount);
 
472
int ocfs2_get_refcount_rec(ocfs2_filesys *fs,
 
473
                           char *ref_root_buf,
 
474
                           uint64_t cpos, unsigned int len,
 
475
                           struct ocfs2_refcount_rec *ret_rec,
 
476
                           int *index,
 
477
                           char *ret_buf);
 
478
errcode_t ocfs2_create_refcount_tree(ocfs2_filesys *fs, uint64_t *refcount_loc);
 
479
errcode_t ocfs2_attach_refcount_tree(ocfs2_filesys *fs,
 
480
                                     uint64_t ino, uint64_t refcount_loc);
344
481
errcode_t ocfs2_swap_dir_entries_from_cpu(void *buf, uint64_t bytes);
345
482
errcode_t ocfs2_swap_dir_entries_to_cpu(void *buf, uint64_t bytes);
346
483
void ocfs2_swap_dir_trailer(struct ocfs2_dir_block_trailer *trailer);
357
494
                           struct ocfs2_dir_entry *de, unsigned long offset);
358
495
void ocfs2_init_dir_trailer(ocfs2_filesys *fs, struct ocfs2_dinode *di,
359
496
                            uint64_t blkno, void *buf);
360
 
 
 
497
errcode_t ocfs2_read_dx_root(ocfs2_filesys *fs, uint64_t block,
 
498
                             void *buf);
 
499
errcode_t ocfs2_read_dx_leaf(ocfs2_filesys *fs, uint64_t block,
 
500
                             void *buf);
 
501
int ocfs2_dir_indexed(struct ocfs2_dinode *di);
 
502
errcode_t ocfs2_dx_dir_truncate(ocfs2_filesys *fs, uint64_t dir);
361
503
errcode_t ocfs2_dir_iterate2(ocfs2_filesys *fs,
362
504
                             uint64_t dir,
363
505
                             int flags,
365
507
                             int (*func)(uint64_t       dir,
366
508
                                         int            entry,
367
509
                                         struct ocfs2_dir_entry *dirent,
 
510
                                         uint64_t blocknr,
368
511
                                         int    offset,
369
512
                                         int    blocksize,
370
513
                                         char   *buf,
375
518
                                   int flags,
376
519
                                   char *block_buf,
377
520
                                   int (*func)(struct ocfs2_dir_entry *dirent,
 
521
                                               uint64_t blocknr,
378
522
                                               int      offset,
379
523
                                               int      blocksize,
380
524
                                               char     *buf,
381
525
                                               void     *priv_data),
382
526
                                   void *priv_data);
383
527
 
 
528
extern errcode_t ocfs2_dx_entries_iterate(ocfs2_filesys *fs,
 
529
                        struct ocfs2_dinode *dir,
 
530
                        int flags,
 
531
                        int (*func)(ocfs2_filesys *fs,
 
532
                                    struct ocfs2_dx_entry_list *entry_list,
 
533
                                    struct ocfs2_dx_root_block *dx_root,
 
534
                                    struct ocfs2_dx_leaf *dx_leaf,
 
535
                                    void *priv_data),
 
536
                        void *priv_data);
 
537
 
 
538
extern errcode_t ocfs2_dx_frees_iterate(ocfs2_filesys *fs,
 
539
                        struct ocfs2_dinode *dir,
 
540
                        struct ocfs2_dx_root_block *dx_root,
 
541
                        int flags,
 
542
                        int (*func)(ocfs2_filesys *fs,
 
543
                                    uint64_t blkno,
 
544
                                    struct ocfs2_dir_block_trailer *trailer,
 
545
                                    char *dirblock,
 
546
                                    void *priv_data),
 
547
                        void *priv_data);
 
548
 
384
549
errcode_t ocfs2_lookup(ocfs2_filesys *fs, uint64_t dir,
385
550
                       const char *name, int namelen, char *buf,
386
551
                       uint64_t *inode);
453
618
errcode_t ocfs2_get_ocfs1_label(char *device, uint8_t *label, uint16_t label_len,
454
619
                                uint8_t *uuid, uint16_t uuid_len);
455
620
 
456
 
void ocfs2_swap_group_desc(struct ocfs2_group_desc *gd);
 
621
void ocfs2_swap_group_desc_from_cpu(ocfs2_filesys *fs,
 
622
                                    struct ocfs2_group_desc *gd);
 
623
void ocfs2_swap_group_desc_to_cpu(ocfs2_filesys *fs,
 
624
                                  struct ocfs2_group_desc *gd);
457
625
errcode_t ocfs2_read_group_desc(ocfs2_filesys *fs, uint64_t blkno,
458
626
                                char *gd_buf);
459
627
 
460
628
errcode_t ocfs2_write_group_desc(ocfs2_filesys *fs, uint64_t blkno,
461
629
                                 char *gd_buf);
 
630
uint64_t ocfs2_get_block_from_group(ocfs2_filesys *fs,
 
631
                                    struct ocfs2_group_desc *grp,
 
632
                                    int bpc, int bit_offset);
462
633
 
463
634
errcode_t ocfs2_chain_iterate(ocfs2_filesys *fs,
464
635
                              uint64_t blkno,
475
646
errcode_t ocfs2_chain_alloc(ocfs2_filesys *fs,
476
647
                            ocfs2_cached_inode *cinode,
477
648
                            uint64_t *gd_blkno,
 
649
                            uint16_t *suballoc_bit,
478
650
                            uint64_t *bitno);
479
651
errcode_t ocfs2_chain_free(ocfs2_filesys *fs,
480
652
                           ocfs2_cached_inode *cinode,
514
686
                           struct ocfs2_group_desc *gd,
515
687
                           uint64_t blkno, uint32_t generation,
516
688
                           uint64_t parent_inode, uint16_t bits,
517
 
                           uint16_t chain);
 
689
                           uint16_t chain, int suballoc);
518
690
 
519
691
errcode_t ocfs2_new_dir_block(ocfs2_filesys *fs, uint64_t dir_ino,
520
692
                              uint64_t parent_ino, char **block);
521
693
 
522
 
errcode_t ocfs2_insert_extent(ocfs2_filesys *fs, uint64_t ino, uint32_t cpos,
523
 
                              uint64_t c_blkno, uint32_t clusters,
524
 
                              uint16_t flag);
 
694
errcode_t ocfs2_inode_insert_extent(ocfs2_filesys *fs, uint64_t ino,
 
695
                                    uint32_t cpos, uint64_t c_blkno,
 
696
                                    uint32_t clusters, uint16_t flag);
525
697
errcode_t ocfs2_cached_inode_insert_extent(ocfs2_cached_inode *ci,
526
698
                                           uint32_t cpos, uint64_t c_blkno,
527
699
                                           uint32_t clusters, uint16_t flag);
533
705
errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino, int mode, int flags);
534
706
errcode_t ocfs2_delete_inode(ocfs2_filesys *fs, uint64_t ino);
535
707
errcode_t ocfs2_new_extent_block(ocfs2_filesys *fs, uint64_t *blkno);
 
708
errcode_t ocfs2_new_dx_root(ocfs2_filesys *fs, struct ocfs2_dinode *di, uint64_t *dr_blkno);
536
709
errcode_t ocfs2_delete_extent_block(ocfs2_filesys *fs, uint64_t blkno);
 
710
errcode_t ocfs2_delete_dx_root(ocfs2_filesys *fs, uint64_t dr_blkno);
 
711
 
537
712
/*
538
713
 * Allocate the blocks and insert them to the file.
539
714
 * only i_clusters of dinode will be updated accordingly, i_size not changed.
540
715
 */
541
716
errcode_t ocfs2_extend_allocation(ocfs2_filesys *fs, uint64_t ino,
542
717
                                  uint32_t new_clusters);
 
718
/* Ditto for cached inode */
 
719
errcode_t ocfs2_cached_inode_extend_allocation(ocfs2_cached_inode *ci,
 
720
                                               uint32_t new_clusters);
543
721
/* Extend the file to the new size. No clusters will be allocated. */
544
722
errcode_t ocfs2_extend_file(ocfs2_filesys *fs, uint64_t ino, uint64_t new_size);
545
723
 
550
728
                                           uint64_t offset, uint64_t len);
551
729
 
552
730
errcode_t ocfs2_truncate(ocfs2_filesys *fs, uint64_t ino, uint64_t new_i_size);
 
731
errcode_t ocfs2_truncate_inline(ocfs2_filesys *fs, uint64_t ino,
 
732
                                uint64_t new_i_size);
553
733
errcode_t ocfs2_truncate_full(ocfs2_filesys *fs, uint64_t ino,
554
734
                              uint64_t new_i_size,
555
735
                              errcode_t (*free_clusters)(ocfs2_filesys *fs,
624
804
 
625
805
errcode_t ocfs2_meta_unlock(ocfs2_filesys *fs, ocfs2_cached_inode *ci);
626
806
 
 
807
/* Quota operations */
 
808
static inline int ocfs2_global_dqstr_in_blk(int blocksize)
 
809
{
 
810
        return (blocksize - OCFS2_QBLK_RESERVED_SPACE -
 
811
                sizeof(struct qt_disk_dqdbheader)) /
 
812
                sizeof(struct ocfs2_global_disk_dqblk);
 
813
}
 
814
void ocfs2_swap_quota_header(struct ocfs2_disk_dqheader *header);
 
815
void ocfs2_swap_quota_local_info(struct ocfs2_local_disk_dqinfo *info);
 
816
void ocfs2_swap_quota_chunk_header(struct ocfs2_local_disk_chunk *chunk);
 
817
void ocfs2_swap_quota_global_info(struct ocfs2_global_disk_dqinfo *info);
 
818
void ocfs2_swap_quota_global_dqblk(struct ocfs2_global_disk_dqblk *dqblk);
 
819
void ocfs2_swap_quota_leaf_block_header(struct qt_disk_dqdbheader *bheader);
 
820
errcode_t ocfs2_init_local_quota_file(ocfs2_filesys *fs, int type,
 
821
                                      uint64_t blkno);
 
822
errcode_t ocfs2_init_local_quota_files(ocfs2_filesys *fs, int type);
 
823
int ocfs2_qtree_depth(int blocksize);
 
824
int ocfs2_qtree_entry_unused(struct ocfs2_global_disk_dqblk *ddquot);
 
825
errcode_t ocfs2_init_global_quota_file(ocfs2_filesys *fs, int type);
 
826
errcode_t ocfs2_init_fs_quota_info(ocfs2_filesys *fs, int type);
 
827
errcode_t ocfs2_read_global_quota_info(ocfs2_filesys *fs, int type);
 
828
errcode_t ocfs2_load_fs_quota_info(ocfs2_filesys *fs);
 
829
errcode_t ocfs2_write_global_quota_info(ocfs2_filesys *fs, int type);
 
830
errcode_t ocfs2_write_dquot(ocfs2_filesys *fs, int type,
 
831
                            ocfs2_cached_dquot *dquot);
 
832
errcode_t ocfs2_delete_dquot(ocfs2_filesys *fs, int type,
 
833
                             ocfs2_cached_dquot *dquot);
 
834
errcode_t ocfs2_read_dquot(ocfs2_filesys *fs, int type, qid_t id,
 
835
                           ocfs2_cached_dquot **ret_dquot);
 
836
errcode_t ocfs2_new_quota_hash(ocfs2_quota_hash **hashp);
 
837
errcode_t ocfs2_free_quota_hash(ocfs2_quota_hash *hash);
 
838
errcode_t ocfs2_insert_quota_hash(ocfs2_quota_hash *hash,
 
839
                                  ocfs2_cached_dquot *dquot);
 
840
errcode_t ocfs2_remove_quota_hash(ocfs2_quota_hash *hash,
 
841
                                  ocfs2_cached_dquot *dquot);
 
842
errcode_t ocfs2_find_quota_hash(ocfs2_quota_hash *hash, qid_t id,
 
843
                                ocfs2_cached_dquot **dquotp);
 
844
errcode_t ocfs2_find_create_quota_hash(ocfs2_quota_hash *hash, qid_t id,
 
845
                                       ocfs2_cached_dquot **dquotp);
 
846
errcode_t ocfs2_find_read_quota_hash(ocfs2_filesys *fs, ocfs2_quota_hash *hash,
 
847
                                     int type, qid_t id,
 
848
                                     ocfs2_cached_dquot **dquotp);
 
849
errcode_t ocfs2_compute_quota_usage(ocfs2_filesys *fs,
 
850
                                    ocfs2_quota_hash *usr_hash,
 
851
                                    ocfs2_quota_hash *grp_hash);
 
852
errcode_t ocfs2_init_quota_change(ocfs2_filesys *fs,
 
853
                                  ocfs2_quota_hash **usrhash,
 
854
                                  ocfs2_quota_hash **grphash);
 
855
errcode_t ocfs2_finish_quota_change(ocfs2_filesys *fs,
 
856
                                    ocfs2_quota_hash *usrhash,
 
857
                                    ocfs2_quota_hash *grphash);
 
858
errcode_t ocfs2_apply_quota_change(ocfs2_filesys *fs,
 
859
                                   ocfs2_quota_hash *usrhash,
 
860
                                   ocfs2_quota_hash *grphash,
 
861
                                   uid_t uid, gid_t gid,
 
862
                                   int64_t space_change,
 
863
                                   int64_t inode_change);
 
864
errcode_t ocfs2_iterate_quota_hash(ocfs2_quota_hash *hash,
 
865
                                   errcode_t (*f)(ocfs2_cached_dquot *, void *),
 
866
                                   void *data);
 
867
errcode_t ocfs2_write_release_dquots(ocfs2_filesys *fs, int type,
 
868
                                     ocfs2_quota_hash *hash);
 
869
 
627
870
/* Low level */
628
871
void ocfs2_swap_slot_map(struct ocfs2_slot_map *sm, int num_slots);
629
872
void ocfs2_swap_slot_map_extended(struct ocfs2_slot_map_extended *se,
720
963
errcode_t ocfs2_snprint_feature_flags(char *str, size_t size,
721
964
                                      ocfs2_fs_options *flags);
722
965
errcode_t ocfs2_snprint_tunefs_flags(char *str, size_t size, uint16_t flags);
 
966
errcode_t ocfs2_snprint_extent_flags(char *str, size_t size, uint8_t flags);
 
967
errcode_t ocfs2_snprint_refcount_flags(char *str, size_t size, uint8_t flags);
723
968
errcode_t ocfs2_parse_feature(const char *opts,
724
969
                              ocfs2_fs_options *feature_flags,
725
970
                              ocfs2_fs_options *reverse_flags);
728
973
                                    enum ocfs2_feature_levels *level);
729
974
 
730
975
errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
 
976
                                               enum ocfs2_mkfs_types fstype,
731
977
                                               int level,
732
978
                                               ocfs2_fs_options *feature_set,
733
979
                                               ocfs2_fs_options *reverse_set);
881
1127
        return ret >> OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
882
1128
}
883
1129
 
 
1130
static inline uint64_t ocfs2_align_bytes_to_clusters(ocfs2_filesys *fs,
 
1131
                                                     uint64_t bytes)
 
1132
{
 
1133
        uint32_t clusters;
 
1134
 
 
1135
        clusters = ocfs2_clusters_in_bytes(fs, bytes);
 
1136
        return (uint64_t)clusters <<
 
1137
                        OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
 
1138
}
 
1139
 
 
1140
static inline uint64_t ocfs2_align_bytes_to_blocks(ocfs2_filesys *fs,
 
1141
                                                   uint64_t bytes)
 
1142
{
 
1143
        uint64_t blocks;
 
1144
 
 
1145
        blocks = ocfs2_blocks_in_bytes(fs, bytes);
 
1146
        return blocks << OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
 
1147
}
884
1148
 
885
1149
/* given a cluster offset, calculate which block group it belongs to
886
1150
 * and return that block offset. */
911
1175
                                             uint64_t blocksize,
912
1176
                                     struct ocfs2_cluster_group_sizes *cgs)
913
1177
{
914
 
        uint16_t max_bits = 8 * ocfs2_group_bitmap_size(blocksize);
 
1178
        uint16_t max_bits = 8 * ocfs2_group_bitmap_size(blocksize, 0, 0);
915
1179
 
916
1180
        cgs->cgs_cpg = max_bits;
917
1181
        if (max_bits > clusters)
1019
1283
        return 0;
1020
1284
}
1021
1285
 
 
1286
static inline int ocfs2_supports_indexed_dirs(struct ocfs2_super_block *osb)
 
1287
{
 
1288
        if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
 
1289
                return 1;
 
1290
        return 0;
 
1291
}
 
1292
 
1022
1293
/*
1023
1294
 * When we're swapping some of our disk structures, a garbage count
1024
1295
 * can send us past the edge of a block buffer.  This function guards
1040
1311
}
1041
1312
 
1042
1313
 
 
1314
static inline int ocfs2_refcount_tree(struct ocfs2_super_block *osb)
 
1315
{
 
1316
        if (OCFS2_HAS_INCOMPAT_FEATURE(osb,
 
1317
                                       OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE))
 
1318
                return 1;
 
1319
        return 0;
 
1320
}
 
1321
 
 
1322
static inline int ocfs2_supports_discontig_bg(struct ocfs2_super_block *osb)
 
1323
{
 
1324
        if (OCFS2_HAS_INCOMPAT_FEATURE(osb,
 
1325
                                        OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
 
1326
                return 1;
 
1327
        return 0;
 
1328
}
 
1329
 
1043
1330
/*
1044
1331
 * shamelessly lifted from the kernel
1045
1332
 *
1101
1388
#define OCFS2_BLOCK_ABORT       0x02
1102
1389
#define OCFS2_BLOCK_ERROR       0x04
1103
1390
 
 
1391
 
 
1392
#define OCFS2_IS_VALID_DX_ROOT(ptr)                                     \
 
1393
                (!strcmp((char *)(ptr)->dr_signature, OCFS2_DX_ROOT_SIGNATURE))
 
1394
 
1104
1395
/*
1105
1396
 * Block iterate flags
1106
1397
 *
1139
1430
                                                 int ref_recno,
1140
1431
                                                 void *priv_data),
1141
1432
                                                 void *priv_data);
 
1433
errcode_t ocfs2_extent_iterate_dx_root(ocfs2_filesys *fs,
 
1434
                                       struct ocfs2_dx_root_block *dx_root,
 
1435
                                       int flags,
 
1436
                                       char *block_buf,
 
1437
                                       int (*func)(ocfs2_filesys *fs,
 
1438
                                                   struct ocfs2_extent_rec *rec,
 
1439
                                                   int tree_depth,
 
1440
                                                   uint32_t ccount,
 
1441
                                                   uint64_t ref_blkno,
 
1442
                                                   int ref_recno,
 
1443
                                                   void *priv_data),
 
1444
                                       void *priv_data);
 
1445
 
1142
1446
errcode_t ocfs2_block_iterate(ocfs2_filesys *fs,
1143
1447
                              uint64_t blkno,
1144
1448
                              int flags,
1158
1462
                                                void *priv_data),
1159
1463
                                    void *priv_data);
1160
1464
 
 
1465
#define OCFS2_XATTR_ABORT       0x01
 
1466
#define OCFS2_XATTR_ERROR       0x02
 
1467
errcode_t ocfs2_xattr_iterate(ocfs2_cached_inode *ci,
 
1468
                              int (*func)(ocfs2_cached_inode *ci,
 
1469
                                          char *xe_buf,
 
1470
                                          uint64_t xe_blkno,
 
1471
                                          struct ocfs2_xattr_entry *xe,
 
1472
                                          char *value_buf,
 
1473
                                          uint64_t value_blkno,
 
1474
                                          void *value,
 
1475
                                          int in_bucket,
 
1476
                                          void *priv_data),
 
1477
                              void *priv_data);
 
1478
 
1161
1479
uint32_t ocfs2_xattr_uuid_hash(unsigned char *uuid);
1162
1480
uint32_t ocfs2_xattr_name_hash(uint32_t uuid_hash, const char *name,
1163
1481
                               int name_len);
1164
 
int ocfs2_xattr_find_leaf(ocfs2_filesys *fs, struct ocfs2_xattr_block *xb,
1165
 
                          uint32_t cpos, char **leaf_buf);
 
1482
int ocfs2_tree_find_leaf(ocfs2_filesys *fs, struct ocfs2_extent_list *el,
 
1483
                         uint64_t el_blkno, char *el_blk,
 
1484
                         uint32_t cpos, char **leaf_buf);
1166
1485
uint16_t ocfs2_xattr_buckets_per_cluster(ocfs2_filesys *fs);
1167
1486
uint16_t ocfs2_blocks_per_xattr_bucket(ocfs2_filesys *fs);
1168
1487
/* See ocfs2_swap_extent_list() for a discussion of obj */
1195
1514
errcode_t ocfs2_write_xattr_bucket(ocfs2_filesys *fs,
1196
1515
                                   uint64_t blkno,
1197
1516
                                   char *bucket_buf);
1198
 
errcode_t ocfs2_xattr_value_truncate(ocfs2_filesys *fs,
 
1517
errcode_t ocfs2_xattr_value_truncate(ocfs2_filesys *fs, uint64_t ino,
1199
1518
                                     struct ocfs2_xattr_value_root *xv);
1200
1519
errcode_t ocfs2_xattr_tree_truncate(ocfs2_filesys *fs,
1201
1520
                                    struct ocfs2_xattr_tree_root *xt);
1213
1532
                                     void *priv_data,
1214
1533
                                     int *changed);
1215
1534
errcode_t ocfs2_delete_xattr_block(ocfs2_filesys *fs, uint64_t blkno);
 
1535
errcode_t ocfs2_dir_indexed_tree_truncate(ocfs2_filesys *fs,
 
1536
                                        struct ocfs2_dx_root_block *dx_root);
 
1537
errcode_t ocfs2_write_dx_root(ocfs2_filesys *fs, uint64_t block, char *buf);
 
1538
errcode_t ocfs2_write_dx_leaf(ocfs2_filesys *fs, uint64_t block, void *buf);
 
1539
errcode_t ocfs2_dx_dir_build(ocfs2_filesys *fs, uint64_t dir);
 
1540
errcode_t ocfs2_dx_dir_insert_entry(ocfs2_filesys *fs, uint64_t dir, const char *name,
 
1541
                                        uint64_t ino, uint64_t blkno);
 
1542
int ocfs2_search_dirblock(ocfs2_filesys *fs, char *dir_buf,
 
1543
                        const char *name, int namelen, unsigned int bytes,
 
1544
                        struct ocfs2_dir_entry **res_dir);
 
1545
void ocfs2_dx_dir_name_hash(ocfs2_filesys *fs, const char *name,
 
1546
                        int len, struct ocfs2_dx_hinfo *hinfo);
 
1547
errcode_t ocfs2_dx_dir_lookup(ocfs2_filesys *fs, struct ocfs2_dx_root_block *dx_root,
 
1548
                        struct ocfs2_extent_list *el, struct ocfs2_dx_hinfo *hinfo,
 
1549
                        uint32_t *ret_cpos, uint64_t *ret_phys_blkno);
 
1550
errcode_t ocfs2_dx_dir_search(ocfs2_filesys *fs, const char *name,
 
1551
                        int namelen, struct ocfs2_dx_root_block *dx_root,
 
1552
                        struct ocfs2_dir_lookup_result *res);
 
1553
void release_lookup_res(struct ocfs2_dir_lookup_result *res);
 
1554
int ocfs2_find_max_rec_len(ocfs2_filesys *fs, char *buf);
 
1555
void ocfs2_dx_list_remove_entry(struct ocfs2_dx_entry_list *entry_list, int index);
 
1556
int ocfs2_is_dir_trailer(ocfs2_filesys *fs, struct ocfs2_dinode *di, unsigned long de_off);
 
1557
/* routines for block check */
 
1558
uint32_t ocfs2_hamming_encode(uint32_t parity, void *data,
 
1559
                                unsigned int d, unsigned int nr);
 
1560
uint32_t ocfs2_hamming_encode_block(void *data, unsigned int d);
 
1561
void ocfs2_hamming_fix(void *data, unsigned int d,
 
1562
                        unsigned int nr, unsigned int fix);
 
1563
void ocfs2_hamming_fix_block(void *data, unsigned int d, unsigned int fix);
 
1564
uint32_t crc32_le(uint32_t crc, unsigned char const *p, size_t len);
 
1565
 
 
1566
 
 
1567
 
1216
1568
 
1217
1569
#endif  /* _FILESYS_H */