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-2006 Red Hat, Inc.  All rights reserved.
0005  */
0006 
0007 #ifndef __BMAP_DOT_H__
0008 #define __BMAP_DOT_H__
0009 
0010 #include <linux/iomap.h>
0011 
0012 #include "inode.h"
0013 
0014 struct inode;
0015 struct gfs2_inode;
0016 struct page;
0017 
0018 
0019 /**
0020  * gfs2_write_calc_reserv - calculate number of blocks needed to write to a file
0021  * @ip: the file
0022  * @len: the number of bytes to be written to the file
0023  * @data_blocks: returns the number of data blocks required
0024  * @ind_blocks: returns the number of indirect blocks required
0025  *
0026  */
0027 
0028 static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip,
0029                       unsigned int len,
0030                       unsigned int *data_blocks,
0031                       unsigned int *ind_blocks)
0032 {
0033     const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
0034     unsigned int tmp;
0035 
0036     BUG_ON(gfs2_is_dir(ip));
0037     *data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3;
0038     *ind_blocks = 3 * (sdp->sd_max_height - 1);
0039 
0040     for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) {
0041         tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
0042         *ind_blocks += tmp;
0043     }
0044 }
0045 
0046 extern const struct iomap_ops gfs2_iomap_ops;
0047 extern const struct iomap_writeback_ops gfs2_writeback_ops;
0048 
0049 extern int gfs2_unstuff_dinode(struct gfs2_inode *ip);
0050 extern int gfs2_block_map(struct inode *inode, sector_t lblock,
0051               struct buffer_head *bh, int create);
0052 extern int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
0053               struct iomap *iomap);
0054 extern int gfs2_iomap_alloc(struct inode *inode, loff_t pos, loff_t length,
0055                 struct iomap *iomap);
0056 extern int gfs2_get_extent(struct inode *inode, u64 lblock, u64 *dblock,
0057                unsigned int *extlen);
0058 extern int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
0059                  unsigned *extlen, bool *new);
0060 extern int gfs2_setattr_size(struct inode *inode, u64 size);
0061 extern void gfs2_trim_blocks(struct inode *inode);
0062 extern int gfs2_truncatei_resume(struct gfs2_inode *ip);
0063 extern int gfs2_file_dealloc(struct gfs2_inode *ip);
0064 extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
0065                      unsigned int len);
0066 extern int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd);
0067 extern void gfs2_free_journal_extents(struct gfs2_jdesc *jd);
0068 extern int __gfs2_punch_hole(struct file *file, loff_t offset, loff_t length);
0069 
0070 #endif /* __BMAP_DOT_H__ */