Thomas Gleixner | 7336d0e | 2019-05-31 01:09:56 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Bob Peterson | fe6c991 | 2008-01-28 11:13:02 -0600 | [diff] [blame] | 4 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __RGRP_DOT_H__ |
| 8 | #define __RGRP_DOT_H__ |
| 9 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Steven Whitehouse | 66fc061 | 2012-02-08 12:58:32 +0000 | [diff] [blame] | 11 | #include <linux/uaccess.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | |
Bob Peterson | 8e2e004 | 2012-07-19 08:12:40 -0400 | [diff] [blame] | 13 | /* Since each block in the file system is represented by two bits in the |
| 14 | * bitmap, one 64-bit word in the bitmap will represent 32 blocks. |
| 15 | * By reserving 32 blocks at a time, we can optimize / shortcut how we search |
| 16 | * through the bitmaps by looking a word at a time. |
| 17 | */ |
Andreas Gruenbacher | ad89945 | 2018-09-25 12:59:31 +0100 | [diff] [blame] | 18 | #define RGRP_RSRV_MINBLKS 32 |
Bob Peterson | 1a85503 | 2014-10-29 08:02:30 -0500 | [diff] [blame] | 19 | #define RGRP_RSRV_ADDBLKS 64 |
Bob Peterson | 8e2e004 | 2012-07-19 08:12:40 -0400 | [diff] [blame] | 20 | |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 21 | struct gfs2_rgrpd; |
| 22 | struct gfs2_sbd; |
| 23 | struct gfs2_holder; |
| 24 | |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 25 | extern void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 26 | |
Steven Whitehouse | 66fc061 | 2012-02-08 12:58:32 +0000 | [diff] [blame] | 27 | extern struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact); |
Steven Whitehouse | 8339ee5 | 2011-08-31 16:38:29 +0100 | [diff] [blame] | 28 | extern struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp); |
| 29 | extern struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 30 | |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 31 | extern void gfs2_clear_rgrpd(struct gfs2_sbd *sdp); |
Steven Whitehouse | 8339ee5 | 2011-08-31 16:38:29 +0100 | [diff] [blame] | 32 | extern int gfs2_rindex_update(struct gfs2_sbd *sdp); |
| 33 | extern void gfs2_free_clones(struct gfs2_rgrpd *rgd); |
Bob Peterson | 7c9ca62 | 2011-08-31 09:53:19 +0100 | [diff] [blame] | 34 | extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); |
Bob Peterson | 39b0f1e | 2015-06-05 08:38:57 -0500 | [diff] [blame] | 35 | extern void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 36 | |
Bob Peterson | 8e2e004 | 2012-07-19 08:12:40 -0400 | [diff] [blame] | 37 | extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip); |
| 38 | |
Steven Whitehouse | 9dbe961 | 2012-10-31 10:37:10 +0000 | [diff] [blame] | 39 | #define GFS2_AF_ORLOV 1 |
Abhi Das | 25435e5 | 2015-03-18 12:04:37 -0500 | [diff] [blame] | 40 | extern int gfs2_inplace_reserve(struct gfs2_inode *ip, |
| 41 | struct gfs2_alloc_parms *ap); |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 42 | extern void gfs2_inplace_release(struct gfs2_inode *ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 43 | |
Bob Peterson | 6e87ed0 | 2011-11-18 10:58:32 -0500 | [diff] [blame] | 44 | extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, |
| 45 | bool dinode, u64 *generation); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 46 | |
Bob Peterson | 2009521 | 2013-03-13 10:26:38 -0400 | [diff] [blame] | 47 | extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs); |
Andreas Gruenbacher | 1595548 | 2020-03-06 10:32:35 -0600 | [diff] [blame] | 48 | extern void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount); |
Andreas Gruenbacher | 0ddeded | 2018-10-04 15:36:02 +0100 | [diff] [blame] | 49 | extern void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd, |
| 50 | u64 bstart, u32 blen, int meta); |
| 51 | extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd, |
| 52 | u64 bstart, u32 blen); |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 53 | extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); |
| 54 | extern void gfs2_unlink_di(struct inode *inode); |
Steven Whitehouse | acf7e24 | 2009-09-08 18:00:30 +0100 | [diff] [blame] | 55 | extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, |
| 56 | unsigned int type); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 57 | |
| 58 | struct gfs2_rgrp_list { |
| 59 | unsigned int rl_rgrps; |
| 60 | unsigned int rl_space; |
| 61 | struct gfs2_rgrpd **rl_rgd; |
| 62 | struct gfs2_holder *rl_ghs; |
| 63 | }; |
| 64 | |
Steven Whitehouse | 70b0c36 | 2011-09-02 16:08:09 +0100 | [diff] [blame] | 65 | extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist, |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 66 | u64 block); |
Bob Peterson | c3abc29 | 2018-10-04 00:06:23 +0100 | [diff] [blame] | 67 | extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist); |
Steven Whitehouse | 0901097 | 2009-05-20 10:48:47 +0100 | [diff] [blame] | 68 | extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); |
| 69 | extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); |
Andrew Price | 0e539ca | 2020-10-07 12:30:58 +0100 | [diff] [blame] | 70 | extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd, |
Bob Peterson | 3792ce9 | 2019-05-09 09:21:48 -0500 | [diff] [blame] | 71 | const char *fs_id_buf); |
Steven Whitehouse | 66fc061 | 2012-02-08 12:58:32 +0000 | [diff] [blame] | 72 | extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset, |
| 73 | struct buffer_head *bh, |
| 74 | const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed); |
| 75 | extern int gfs2_fitrim(struct file *filp, void __user *argp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 76 | |
Steven Whitehouse | 4a993fb | 2012-07-31 15:21:20 +0100 | [diff] [blame] | 77 | /* This is how to tell if a reservation is in the rgrp tree: */ |
Bob Peterson | a097dc7e | 2015-07-16 08:28:04 -0500 | [diff] [blame] | 78 | static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs) |
Bob Peterson | 8e2e004 | 2012-07-19 08:12:40 -0400 | [diff] [blame] | 79 | { |
Steven Whitehouse | 4a993fb | 2012-07-31 15:21:20 +0100 | [diff] [blame] | 80 | return rs && !RB_EMPTY_NODE(&rs->rs_node); |
Bob Peterson | 8e2e004 | 2012-07-19 08:12:40 -0400 | [diff] [blame] | 81 | } |
| 82 | |
Bob Peterson | d552a2b | 2017-02-06 08:28:32 -0500 | [diff] [blame] | 83 | static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block) |
| 84 | { |
| 85 | u64 first = rgd->rd_data0; |
| 86 | u64 last = first + rgd->rd_data; |
| 87 | return first <= block && block < last; |
| 88 | } |
| 89 | |
Abhi Das | 00a158b | 2014-09-18 21:40:28 -0500 | [diff] [blame] | 90 | extern void check_and_update_goal(struct gfs2_inode *ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 91 | #endif /* __RGRP_DOT_H__ */ |