Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
0004  * Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
0005  */
0006 
0007 #ifndef __RGRP_DOT_H__
0008 #define __RGRP_DOT_H__
0009 
0010 #include <linux/slab.h>
0011 #include <linux/uaccess.h>
0012 
0013 /* Since each block in the file system is represented by two bits in the
0014  * bitmap, one 64-bit word in the bitmap will represent 32 blocks.
0015  * By reserving 32 blocks at a time, we can optimize / shortcut how we search
0016  * through the bitmaps by looking a word at a time.
0017  */
0018 #define RGRP_RSRV_MINBLKS 32
0019 #define RGRP_RSRV_ADDBLKS 64
0020 
0021 struct gfs2_rgrpd;
0022 struct gfs2_sbd;
0023 struct gfs2_holder;
0024 
0025 extern void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd);
0026 
0027 extern struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact);
0028 extern struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp);
0029 extern struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd);
0030 
0031 extern void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);
0032 extern int gfs2_rindex_update(struct gfs2_sbd *sdp);
0033 extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);
0034 extern int gfs2_rgrp_go_instantiate(struct gfs2_glock *gl);
0035 extern void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd);
0036 
0037 extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
0038 
0039 #define GFS2_AF_ORLOV 1
0040 extern int gfs2_inplace_reserve(struct gfs2_inode *ip,
0041                 struct gfs2_alloc_parms *ap);
0042 extern void gfs2_inplace_release(struct gfs2_inode *ip);
0043 
0044 extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
0045                  bool dinode, u64 *generation);
0046 
0047 extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
0048 extern void gfs2_rs_delete(struct gfs2_inode *ip);
0049 extern void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
0050                    u64 bstart, u32 blen, int meta);
0051 extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
0052                u64 bstart, u32 blen);
0053 extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
0054 extern void gfs2_unlink_di(struct inode *inode);
0055 extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr,
0056                    unsigned int type);
0057 
0058 struct gfs2_rgrp_list {
0059     unsigned int rl_rgrps;
0060     unsigned int rl_space;
0061     struct gfs2_rgrpd **rl_rgd;
0062     struct gfs2_holder *rl_ghs;
0063 };
0064 
0065 extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
0066                u64 block);
0067 extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist,
0068                  unsigned int state, u16 flags);
0069 extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
0070 extern u64 gfs2_ri_total(struct gfs2_sbd *sdp);
0071 extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd,
0072                const char *fs_id_buf);
0073 extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
0074                    struct buffer_head *bh,
0075                    const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);
0076 extern int gfs2_fitrim(struct file *filp, void __user *argp);
0077 
0078 /* This is how to tell if a reservation is in the rgrp tree: */
0079 static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs)
0080 {
0081     return !RB_EMPTY_NODE(&rs->rs_node);
0082 }
0083 
0084 static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block)
0085 {
0086     u64 first = rgd->rd_data0;
0087     u64 last = first + rgd->rd_data;
0088     return first <= block && block < last;
0089 }
0090 
0091 extern void check_and_update_goal(struct gfs2_inode *ip);
0092 
0093 extern void rgrp_lock_local(struct gfs2_rgrpd *rgd);
0094 extern void rgrp_unlock_local(struct gfs2_rgrpd *rgd);
0095 
0096 #endif /* __RGRP_DOT_H__ */