blob: 66b51cf66dfa3ca7f29a5ad7879d3485e956c462 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Bob Petersonfe6c9912008-01-28 11:13:02 -06003 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
10#ifndef __RGRP_DOT_H__
11#define __RGRP_DOT_H__
12
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Steven Whitehouse66fc0612012-02-08 12:58:32 +000014#include <linux/uaccess.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015
Bob Peterson8e2e0042012-07-19 08:12:40 -040016/* Since each block in the file system is represented by two bits in the
17 * bitmap, one 64-bit word in the bitmap will represent 32 blocks.
18 * By reserving 32 blocks at a time, we can optimize / shortcut how we search
19 * through the bitmaps by looking a word at a time.
20 */
21#define RGRP_RSRV_MINBYTES 8
22#define RGRP_RSRV_MINBLKS ((u32)(RGRP_RSRV_MINBYTES * GFS2_NBBY))
Bob Peterson1a855032014-10-29 08:02:30 -050023#define RGRP_RSRV_ADDBLKS 64
Bob Peterson8e2e0042012-07-19 08:12:40 -040024
Steven Whitehousef2f7ba52006-09-05 10:39:21 -040025struct gfs2_rgrpd;
26struct gfs2_sbd;
27struct gfs2_holder;
28
Steven Whitehouse09010972009-05-20 10:48:47 +010029extern void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd);
David Teiglandb3b94fa2006-01-16 16:50:04 +000030
Steven Whitehouse66fc0612012-02-08 12:58:32 +000031extern struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact);
Steven Whitehouse8339ee52011-08-31 16:38:29 +010032extern struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp);
33extern struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd);
David Teiglandb3b94fa2006-01-16 16:50:04 +000034
Steven Whitehouse09010972009-05-20 10:48:47 +010035extern void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);
Steven Whitehouse8339ee52011-08-31 16:38:29 +010036extern int gfs2_rindex_update(struct gfs2_sbd *sdp);
37extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);
Bob Peterson7c9ca622011-08-31 09:53:19 +010038extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh);
Bob Peterson39b0f1e2015-06-05 08:38:57 -050039extern void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd);
Bob Peterson7c9ca622011-08-31 09:53:19 +010040extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh);
David Teiglandb3b94fa2006-01-16 16:50:04 +000041
Bob Peterson8e2e0042012-07-19 08:12:40 -040042extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
43
Steven Whitehouse9dbe9612012-10-31 10:37:10 +000044#define GFS2_AF_ORLOV 1
Abhi Das25435e52015-03-18 12:04:37 -050045extern int gfs2_inplace_reserve(struct gfs2_inode *ip,
46 struct gfs2_alloc_parms *ap);
Steven Whitehouse09010972009-05-20 10:48:47 +010047extern void gfs2_inplace_release(struct gfs2_inode *ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +000048
Bob Peterson6e87ed02011-11-18 10:58:32 -050049extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
50 bool dinode, u64 *generation);
David Teiglandb3b94fa2006-01-16 16:50:04 +000051
Bob Petersonb54e9a02015-10-26 10:40:28 -050052extern int gfs2_rsqa_alloc(struct gfs2_inode *ip);
Bob Peterson20095212013-03-13 10:26:38 -040053extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
Bob Petersonb54e9a02015-10-26 10:40:28 -050054extern void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount);
Eric Sandeen46fcb2e2011-06-23 10:39:34 -050055extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta);
Steven Whitehouse09010972009-05-20 10:48:47 +010056extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen);
57extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
58extern void gfs2_unlink_di(struct inode *inode);
Steven Whitehouseacf7e242009-09-08 18:00:30 +010059extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr,
60 unsigned int type);
David Teiglandb3b94fa2006-01-16 16:50:04 +000061
62struct gfs2_rgrp_list {
63 unsigned int rl_rgrps;
64 unsigned int rl_space;
65 struct gfs2_rgrpd **rl_rgd;
66 struct gfs2_holder *rl_ghs;
67};
68
Steven Whitehouse70b0c362011-09-02 16:08:09 +010069extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
Steven Whitehouse09010972009-05-20 10:48:47 +010070 u64 block);
71extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state);
72extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
73extern u64 gfs2_ri_total(struct gfs2_sbd *sdp);
Steven Whitehouseac3beb62014-01-16 10:31:13 +000074extern void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl);
Steven Whitehouse66fc0612012-02-08 12:58:32 +000075extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
76 struct buffer_head *bh,
77 const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);
78extern int gfs2_fitrim(struct file *filp, void __user *argp);
David Teiglandb3b94fa2006-01-16 16:50:04 +000079
Steven Whitehouse4a993fb2012-07-31 15:21:20 +010080/* This is how to tell if a reservation is in the rgrp tree: */
Bob Petersona097dc7e2015-07-16 08:28:04 -050081static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs)
Bob Peterson8e2e0042012-07-19 08:12:40 -040082{
Steven Whitehouse4a993fb2012-07-31 15:21:20 +010083 return rs && !RB_EMPTY_NODE(&rs->rs_node);
Bob Peterson8e2e0042012-07-19 08:12:40 -040084}
85
Abhi Das00a158b2014-09-18 21:40:28 -050086extern void check_and_update_goal(struct gfs2_inode *ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +000087#endif /* __RGRP_DOT_H__ */