All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [gfs2:for-next 1/2] fs/gfs2/file.c:948:12: error: invalid storage class for function 'fallocate_chunk'
@ 2021-05-11 18:42 ` kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-05-11 18:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next
head:   5bec51f9bc58e6d724fa3588b77e4c2f865dd13a
commit: a1381d36d843d4f108fe24b384a8a24694fe0bb5 [1/2] gfs2: Prevent direct-I/O write fallback errors from getting lost
config: parisc-randconfig-r002-20210511 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=a1381d36d843d4f108fe24b384a8a24694fe0bb5
        git remote add gfs2 https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
        git fetch --no-tags gfs2 for-next
        git checkout a1381d36d843d4f108fe24b384a8a24694fe0bb5
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   fs/gfs2/file.c: In function 'gfs2_file_write_iter':
>> fs/gfs2/file.c:948:12: error: invalid storage class for function 'fallocate_chunk'
     948 | static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
         |            ^~~~~~~~~~~~~~~
>> fs/gfs2/file.c:948:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     948 | static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
         | ^~~~~~
>> fs/gfs2/file.c:1002:13: error: invalid storage class for function 'calc_max_reserv'
    1002 | static void calc_max_reserv(struct gfs2_inode *ip, loff_t *len,
         |             ^~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1024:13: error: invalid storage class for function '__gfs2_fallocate'
    1024 | static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
         |             ^~~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1140:13: error: invalid storage class for function 'gfs2_fallocate'
    1140 | static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
         |             ^~~~~~~~~~~~~~
>> fs/gfs2/file.c:1189:16: error: invalid storage class for function 'gfs2_file_splice_write'
    1189 | static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe,
         |                ^~~~~~~~~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1393:1: error: expected declaration or statement at end of input
    1393 | };
         | ^
   fs/gfs2/file.c:1385:30: warning: unused variable 'gfs2_dir_fops_nolock' [-Wunused-variable]
    1385 | const struct file_operations gfs2_dir_fops_nolock = {
         |                              ^~~~~~~~~~~~~~~~~~~~
   fs/gfs2/file.c:1368:30: warning: unused variable 'gfs2_file_fops_nolock' [-Wunused-variable]
    1368 | const struct file_operations gfs2_file_fops_nolock = {
         |                              ^~~~~~~~~~~~~~~~~~~~~
   At top level:
   fs/gfs2/file.c:872:16: warning: 'gfs2_file_write_iter' defined but not used [-Wunused-function]
     872 | static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
         |                ^~~~~~~~~~~~~~~~~~~~


vim +/fallocate_chunk +948 fs/gfs2/file.c

56aa616a03feca Steven Whitehouse   2009-12-08   947  
2fe17c1075836b Christoph Hellwig   2011-01-14  @948  static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
2fe17c1075836b Christoph Hellwig   2011-01-14   949  			   int mode)
2fe17c1075836b Christoph Hellwig   2011-01-14   950  {
fffb64127adc3e Andreas Gruenbacher 2018-03-29   951  	struct super_block *sb = inode->i_sb;
2fe17c1075836b Christoph Hellwig   2011-01-14   952  	struct gfs2_inode *ip = GFS2_I(inode);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   953  	loff_t end = offset + len;
2fe17c1075836b Christoph Hellwig   2011-01-14   954  	struct buffer_head *dibh;
2fe17c1075836b Christoph Hellwig   2011-01-14   955  	int error;
2fe17c1075836b Christoph Hellwig   2011-01-14   956  
2fe17c1075836b Christoph Hellwig   2011-01-14   957  	error = gfs2_meta_inode_buffer(ip, &dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   958  	if (unlikely(error))
64dd153c83743a Benjamin Marzinski  2011-09-12   959  		return error;
2fe17c1075836b Christoph Hellwig   2011-01-14   960  
350a9b0a7269c6 Steven Whitehouse   2012-12-14   961  	gfs2_trans_add_meta(ip->i_gl, dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   962  
2fe17c1075836b Christoph Hellwig   2011-01-14   963  	if (gfs2_is_stuffed(ip)) {
2fe17c1075836b Christoph Hellwig   2011-01-14   964  		error = gfs2_unstuff_dinode(ip, NULL);
2fe17c1075836b Christoph Hellwig   2011-01-14   965  		if (unlikely(error))
2fe17c1075836b Christoph Hellwig   2011-01-14   966  			goto out;
2fe17c1075836b Christoph Hellwig   2011-01-14   967  	}
2fe17c1075836b Christoph Hellwig   2011-01-14   968  
fffb64127adc3e Andreas Gruenbacher 2018-03-29   969  	while (offset < end) {
c25892827c7996 Andreas Gruenbacher 2018-07-06   970  		struct iomap iomap = { };
c25892827c7996 Andreas Gruenbacher 2018-07-06   971  
54992257fe4bb9 Andreas Gruenbacher 2021-03-27   972  		error = gfs2_iomap_alloc(inode, offset, end - offset, &iomap);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   973  		if (error)
64dd153c83743a Benjamin Marzinski  2011-09-12   974  			goto out;
fffb64127adc3e Andreas Gruenbacher 2018-03-29   975  		offset = iomap.offset + iomap.length;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24   976  		if (!(iomap.flags & IOMAP_F_NEW))
64dd153c83743a Benjamin Marzinski  2011-09-12   977  			continue;
fffb64127adc3e Andreas Gruenbacher 2018-03-29   978  		error = sb_issue_zeroout(sb, iomap.addr >> inode->i_blkbits,
fffb64127adc3e Andreas Gruenbacher 2018-03-29   979  					 iomap.length >> inode->i_blkbits,
fffb64127adc3e Andreas Gruenbacher 2018-03-29   980  					 GFP_NOFS);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   981  		if (error) {
fffb64127adc3e Andreas Gruenbacher 2018-03-29   982  			fs_err(GFS2_SB(inode), "Failed to zero data buffers\n");
2fe17c1075836b Christoph Hellwig   2011-01-14   983  			goto out;
2fe17c1075836b Christoph Hellwig   2011-01-14   984  		}
64dd153c83743a Benjamin Marzinski  2011-09-12   985  	}
2fe17c1075836b Christoph Hellwig   2011-01-14   986  out:
64dd153c83743a Benjamin Marzinski  2011-09-12   987  	brelse(dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   988  	return error;
2fe17c1075836b Christoph Hellwig   2011-01-14   989  }
f3b64b57c044fe Andreas Gruenbacher 2019-08-31   990  
d9be0cda774e7f Abhi Das            2015-03-18   991  /**
d9be0cda774e7f Abhi Das            2015-03-18   992   * calc_max_reserv() - Reverse of write_calc_reserv. Given a number of
d9be0cda774e7f Abhi Das            2015-03-18   993   *                     blocks, determine how many bytes can be written.
d9be0cda774e7f Abhi Das            2015-03-18   994   * @ip:          The inode in question.
d9be0cda774e7f Abhi Das            2015-03-18   995   * @len:         Max cap of bytes. What we return in *len must be <= this.
d9be0cda774e7f Abhi Das            2015-03-18   996   * @data_blocks: Compute and return the number of data blocks needed
d9be0cda774e7f Abhi Das            2015-03-18   997   * @ind_blocks:  Compute and return the number of indirect blocks needed
d9be0cda774e7f Abhi Das            2015-03-18   998   * @max_blocks:  The total blocks available to work with.
d9be0cda774e7f Abhi Das            2015-03-18   999   *
d9be0cda774e7f Abhi Das            2015-03-18  1000   * Returns: void, but @len, @data_blocks and @ind_blocks are filled in.
d9be0cda774e7f Abhi Das            2015-03-18  1001   */
d9be0cda774e7f Abhi Das            2015-03-18 @1002  static void calc_max_reserv(struct gfs2_inode *ip, loff_t *len,
d9be0cda774e7f Abhi Das            2015-03-18  1003  			    unsigned int *data_blocks, unsigned int *ind_blocks,
d9be0cda774e7f Abhi Das            2015-03-18  1004  			    unsigned int max_blocks)
2fe17c1075836b Christoph Hellwig   2011-01-14  1005  {
d9be0cda774e7f Abhi Das            2015-03-18  1006  	loff_t max = *len;
2fe17c1075836b Christoph Hellwig   2011-01-14  1007  	const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1008  	unsigned int tmp, max_data = max_blocks - 3 * (sdp->sd_max_height - 1);
2fe17c1075836b Christoph Hellwig   2011-01-14  1009  
2fe17c1075836b Christoph Hellwig   2011-01-14  1010  	for (tmp = max_data; tmp > sdp->sd_diptrs;) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1011  		tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
2fe17c1075836b Christoph Hellwig   2011-01-14  1012  		max_data -= tmp;
2fe17c1075836b Christoph Hellwig   2011-01-14  1013  	}
d9be0cda774e7f Abhi Das            2015-03-18  1014  
2fe17c1075836b Christoph Hellwig   2011-01-14  1015  	*data_blocks = max_data;
2fe17c1075836b Christoph Hellwig   2011-01-14  1016  	*ind_blocks = max_blocks - max_data;
2fe17c1075836b Christoph Hellwig   2011-01-14  1017  	*len = ((loff_t)max_data - 3) << sdp->sd_sb.sb_bsize_shift;
2fe17c1075836b Christoph Hellwig   2011-01-14  1018  	if (*len > max) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1019  		*len = max;
2fe17c1075836b Christoph Hellwig   2011-01-14  1020  		gfs2_write_calc_reserv(ip, max, data_blocks, ind_blocks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1021  	}
2fe17c1075836b Christoph Hellwig   2011-01-14  1022  }
2fe17c1075836b Christoph Hellwig   2011-01-14  1023  
9c9f1159a54c61 Andrew Price        2014-11-12 @1024  static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
2fe17c1075836b Christoph Hellwig   2011-01-14  1025  {
496ad9aa8ef448 Al Viro             2013-01-23  1026  	struct inode *inode = file_inode(file);
2fe17c1075836b Christoph Hellwig   2011-01-14  1027  	struct gfs2_sbd *sdp = GFS2_SB(inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1028  	struct gfs2_inode *ip = GFS2_I(inode);
7b9cff467144c8 Steven Whitehouse   2013-10-02  1029  	struct gfs2_alloc_parms ap = { .aflags = 0, };
2fe17c1075836b Christoph Hellwig   2011-01-14  1030  	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1031  	loff_t bytes, max_bytes, max_blks;
2fe17c1075836b Christoph Hellwig   2011-01-14  1032  	int error;
4442f2e03ed964 Steven Whitehouse   2011-11-21  1033  	const loff_t pos = offset;
4442f2e03ed964 Steven Whitehouse   2011-11-21  1034  	const loff_t count = len;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1035  	loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
2fe17c1075836b Christoph Hellwig   2011-01-14  1036  	loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
64dd153c83743a Benjamin Marzinski  2011-09-12  1037  	loff_t max_chunk_size = UINT_MAX & bsize_mask;
a0846a534c5fbc Bob Peterson        2014-02-06  1038  
2fe17c1075836b Christoph Hellwig   2011-01-14  1039  	next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
2fe17c1075836b Christoph Hellwig   2011-01-14  1040  
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1041  	offset &= bsize_mask;
2fe17c1075836b Christoph Hellwig   2011-01-14  1042  
2fe17c1075836b Christoph Hellwig   2011-01-14  1043  	len = next - offset;
2fe17c1075836b Christoph Hellwig   2011-01-14  1044  	bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2;
2fe17c1075836b Christoph Hellwig   2011-01-14  1045  	if (!bytes)
2fe17c1075836b Christoph Hellwig   2011-01-14  1046  		bytes = UINT_MAX;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1047  	bytes &= bsize_mask;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1048  	if (bytes == 0)
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1049  		bytes = sdp->sd_sb.sb_bsize;
2fe17c1075836b Christoph Hellwig   2011-01-14  1050  
da1dfb6af849cb Steven Whitehouse   2012-07-26  1051  	gfs2_size_hint(file, offset, len);
8e2e00473598dd Bob Peterson        2012-07-19  1052  
d9be0cda774e7f Abhi Das            2015-03-18  1053  	gfs2_write_calc_reserv(ip, PAGE_SIZE, &data_blocks, &ind_blocks);
d9be0cda774e7f Abhi Das            2015-03-18  1054  	ap.min_target = data_blocks + ind_blocks;
d9be0cda774e7f Abhi Das            2015-03-18  1055  
2fe17c1075836b Christoph Hellwig   2011-01-14  1056  	while (len > 0) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1057  		if (len < bytes)
2fe17c1075836b Christoph Hellwig   2011-01-14  1058  			bytes = len;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1059  		if (!gfs2_write_alloc_required(ip, offset, bytes)) {
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1060  			len -= bytes;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1061  			offset += bytes;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1062  			continue;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1063  		}
d9be0cda774e7f Abhi Das            2015-03-18  1064  
d9be0cda774e7f Abhi Das            2015-03-18  1065  		/* We need to determine how many bytes we can actually
d9be0cda774e7f Abhi Das            2015-03-18  1066  		 * fallocate without exceeding quota or going over the
d9be0cda774e7f Abhi Das            2015-03-18  1067  		 * end of the fs. We start off optimistically by assuming
d9be0cda774e7f Abhi Das            2015-03-18  1068  		 * we can write max_bytes */
d9be0cda774e7f Abhi Das            2015-03-18  1069  		max_bytes = (len > max_chunk_size) ? max_chunk_size : len;
d9be0cda774e7f Abhi Das            2015-03-18  1070  
d9be0cda774e7f Abhi Das            2015-03-18  1071  		/* Since max_bytes is most likely a theoretical max, we
d9be0cda774e7f Abhi Das            2015-03-18  1072  		 * calculate a more realistic 'bytes' to serve as a good
d9be0cda774e7f Abhi Das            2015-03-18  1073  		 * starting point for the number of bytes we may be able
d9be0cda774e7f Abhi Das            2015-03-18  1074  		 * to write */
2fe17c1075836b Christoph Hellwig   2011-01-14  1075  		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
7b9cff467144c8 Steven Whitehouse   2013-10-02  1076  		ap.target = data_blocks + ind_blocks;
b8fbf471edb3db Abhi Das            2015-03-18  1077  
b8fbf471edb3db Abhi Das            2015-03-18  1078  		error = gfs2_quota_lock_check(ip, &ap);
2fe17c1075836b Christoph Hellwig   2011-01-14  1079  		if (error)
9c9f1159a54c61 Andrew Price        2014-11-12  1080  			return error;
d9be0cda774e7f Abhi Das            2015-03-18  1081  		/* ap.allowed tells us how many blocks quota will allow
d9be0cda774e7f Abhi Das            2015-03-18  1082  		 * us to write. Check if this reduces max_blks */
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1083  		max_blks = UINT_MAX;
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1084  		if (ap.allowed)
d9be0cda774e7f Abhi Das            2015-03-18  1085  			max_blks = ap.allowed;
2fe17c1075836b Christoph Hellwig   2011-01-14  1086  
7b9cff467144c8 Steven Whitehouse   2013-10-02  1087  		error = gfs2_inplace_reserve(ip, &ap);
d9be0cda774e7f Abhi Das            2015-03-18  1088  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1089  			goto out_qunlock;
d9be0cda774e7f Abhi Das            2015-03-18  1090  
d9be0cda774e7f Abhi Das            2015-03-18  1091  		/* check if the selected rgrp limits our max_blks further */
725d0e9d464d56 Andreas Gruenbacher 2018-10-02  1092  		if (ip->i_res.rs_reserved < max_blks)
725d0e9d464d56 Andreas Gruenbacher 2018-10-02  1093  			max_blks = ip->i_res.rs_reserved;
d9be0cda774e7f Abhi Das            2015-03-18  1094  
d9be0cda774e7f Abhi Das            2015-03-18  1095  		/* Almost done. Calculate bytes that can be written using
d9be0cda774e7f Abhi Das            2015-03-18  1096  		 * max_blks. We also recompute max_bytes, data_blocks and
d9be0cda774e7f Abhi Das            2015-03-18  1097  		 * ind_blocks */
d9be0cda774e7f Abhi Das            2015-03-18  1098  		calc_max_reserv(ip, &max_bytes, &data_blocks,
d9be0cda774e7f Abhi Das            2015-03-18  1099  				&ind_blocks, max_blks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1100  
2fe17c1075836b Christoph Hellwig   2011-01-14  1101  		rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA +
71f890f7f758f3 Steven Whitehouse   2012-07-30  1102  			  RES_RG_HDR + gfs2_rg_blocks(ip, data_blocks + ind_blocks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1103  		if (gfs2_is_jdata(ip))
2fe17c1075836b Christoph Hellwig   2011-01-14  1104  			rblocks += data_blocks ? data_blocks : 1;
2fe17c1075836b Christoph Hellwig   2011-01-14  1105  
2fe17c1075836b Christoph Hellwig   2011-01-14  1106  		error = gfs2_trans_begin(sdp, rblocks,
45eb05042d5667 Andreas Gruenbacher 2019-09-02  1107  					 PAGE_SIZE >> inode->i_blkbits);
2fe17c1075836b Christoph Hellwig   2011-01-14  1108  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1109  			goto out_trans_fail;
2fe17c1075836b Christoph Hellwig   2011-01-14  1110  
2fe17c1075836b Christoph Hellwig   2011-01-14  1111  		error = fallocate_chunk(inode, offset, max_bytes, mode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1112  		gfs2_trans_end(sdp);
2fe17c1075836b Christoph Hellwig   2011-01-14  1113  
2fe17c1075836b Christoph Hellwig   2011-01-14  1114  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1115  			goto out_trans_fail;
2fe17c1075836b Christoph Hellwig   2011-01-14  1116  
2fe17c1075836b Christoph Hellwig   2011-01-14  1117  		len -= max_bytes;
2fe17c1075836b Christoph Hellwig   2011-01-14  1118  		offset += max_bytes;
2fe17c1075836b Christoph Hellwig   2011-01-14  1119  		gfs2_inplace_release(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1120  		gfs2_quota_unlock(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1121  	}
4442f2e03ed964 Steven Whitehouse   2011-11-21  1122  
0a6a4abc84668d Andreas Gruenbacher 2019-08-08  1123  	if (!(mode & FALLOC_FL_KEEP_SIZE) && (pos + count) > inode->i_size)
1885867b84d58e Andrew Price        2014-11-12  1124  		i_size_write(inode, pos + count);
98f1a696a1b2f6 Andrew Price        2014-11-12  1125  	file_update_time(file);
4b813f09405823 Andrew Price        2015-09-22  1126  	mark_inode_dirty(inode);
1885867b84d58e Andrew Price        2014-11-12  1127  
dde0c2e7984829 Christoph Hellwig   2016-04-07  1128  	if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
dde0c2e7984829 Christoph Hellwig   2016-04-07  1129  		return vfs_fsync_range(file, pos, pos + count - 1,
dde0c2e7984829 Christoph Hellwig   2016-04-07  1130  			       (file->f_flags & __O_SYNC) ? 0 : 1);
dde0c2e7984829 Christoph Hellwig   2016-04-07  1131  	return 0;
2fe17c1075836b Christoph Hellwig   2011-01-14  1132  
2fe17c1075836b Christoph Hellwig   2011-01-14  1133  out_trans_fail:
2fe17c1075836b Christoph Hellwig   2011-01-14  1134  	gfs2_inplace_release(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1135  out_qunlock:
2fe17c1075836b Christoph Hellwig   2011-01-14  1136  	gfs2_quota_unlock(ip);
9c9f1159a54c61 Andrew Price        2014-11-12  1137  	return error;
9c9f1159a54c61 Andrew Price        2014-11-12  1138  }
9c9f1159a54c61 Andrew Price        2014-11-12  1139  
9c9f1159a54c61 Andrew Price        2014-11-12 @1140  static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
9c9f1159a54c61 Andrew Price        2014-11-12  1141  {
9c9f1159a54c61 Andrew Price        2014-11-12  1142  	struct inode *inode = file_inode(file);
d4d7fc12b642a1 Andrew Price        2017-04-05  1143  	struct gfs2_sbd *sdp = GFS2_SB(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1144  	struct gfs2_inode *ip = GFS2_I(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1145  	struct gfs2_holder gh;
9c9f1159a54c61 Andrew Price        2014-11-12  1146  	int ret;
9c9f1159a54c61 Andrew Price        2014-11-12  1147  
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1148  	if (mode & ~(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE))
d4d7fc12b642a1 Andrew Price        2017-04-05  1149  		return -EOPNOTSUPP;
d4d7fc12b642a1 Andrew Price        2017-04-05  1150  	/* fallocate is needed by gfs2_grow to reserve space in the rindex */
d4d7fc12b642a1 Andrew Price        2017-04-05  1151  	if (gfs2_is_jdata(ip) && inode != sdp->sd_rindex)
9c9f1159a54c61 Andrew Price        2014-11-12  1152  		return -EOPNOTSUPP;
9c9f1159a54c61 Andrew Price        2014-11-12  1153  
5955102c9984fa Al Viro             2016-01-22  1154  	inode_lock(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1155  
9c9f1159a54c61 Andrew Price        2014-11-12  1156  	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
9c9f1159a54c61 Andrew Price        2014-11-12  1157  	ret = gfs2_glock_nq(&gh);
9c9f1159a54c61 Andrew Price        2014-11-12  1158  	if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1159  		goto out_uninit;
9c9f1159a54c61 Andrew Price        2014-11-12  1160  
9c9f1159a54c61 Andrew Price        2014-11-12  1161  	if (!(mode & FALLOC_FL_KEEP_SIZE) &&
9c9f1159a54c61 Andrew Price        2014-11-12  1162  	    (offset + len) > inode->i_size) {
9c9f1159a54c61 Andrew Price        2014-11-12  1163  		ret = inode_newsize_ok(inode, offset + len);
9c9f1159a54c61 Andrew Price        2014-11-12  1164  		if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1165  			goto out_unlock;
9c9f1159a54c61 Andrew Price        2014-11-12  1166  	}
9c9f1159a54c61 Andrew Price        2014-11-12  1167  
9c9f1159a54c61 Andrew Price        2014-11-12  1168  	ret = get_write_access(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1169  	if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1170  		goto out_unlock;
9c9f1159a54c61 Andrew Price        2014-11-12  1171  
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1172  	if (mode & FALLOC_FL_PUNCH_HOLE) {
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1173  		ret = __gfs2_punch_hole(file, offset, len);
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1174  	} else {
9c9f1159a54c61 Andrew Price        2014-11-12  1175  		ret = __gfs2_fallocate(file, mode, offset, len);
9c9f1159a54c61 Andrew Price        2014-11-12  1176  		if (ret)
a097dc7e24cba7 Bob Peterson        2015-07-16  1177  			gfs2_rs_deltree(&ip->i_res);
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1178  	}
a097dc7e24cba7 Bob Peterson        2015-07-16  1179  
9c9f1159a54c61 Andrew Price        2014-11-12  1180  	put_write_access(inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1181  out_unlock:
a0846a534c5fbc Bob Peterson        2014-02-06  1182  	gfs2_glock_dq(&gh);
2fe17c1075836b Christoph Hellwig   2011-01-14  1183  out_uninit:
a0846a534c5fbc Bob Peterson        2014-02-06  1184  	gfs2_holder_uninit(&gh);
5955102c9984fa Al Viro             2016-01-22  1185  	inode_unlock(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1186  	return ret;
2fe17c1075836b Christoph Hellwig   2011-01-14  1187  }
2fe17c1075836b Christoph Hellwig   2011-01-14  1188  

:::::: The code at line 948 was first introduced by commit
:::::: 2fe17c1075836b66678ed2a305fd09b6773883aa fallocate should be a file operation

:::::: TO: Christoph Hellwig <hch@lst.de>
:::::: CC: Al Viro <viro@zeniv.linux.org.uk>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 38948 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20210512/04546d9e/attachment.gz>

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [Cluster-devel] [gfs2:for-next 1/2] fs/gfs2/file.c:948:12: error: invalid storage class for function 'fallocate_chunk'
@ 2021-05-11 18:46 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-05-11 18:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next
head:   5bec51f9bc58e6d724fa3588b77e4c2f865dd13a
commit: a1381d36d843d4f108fe24b384a8a24694fe0bb5 [1/2] gfs2: Prevent direct-I/O write fallback errors from getting lost
config: m68k-randconfig-r016-20210511 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=a1381d36d843d4f108fe24b384a8a24694fe0bb5
        git remote add gfs2 https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
        git fetch --no-tags gfs2 for-next
        git checkout a1381d36d843d4f108fe24b384a8a24694fe0bb5
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   fs/gfs2/file.c: In function 'gfs2_file_write_iter':
>> fs/gfs2/file.c:948:12: error: invalid storage class for function 'fallocate_chunk'
     948 | static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
         |            ^~~~~~~~~~~~~~~
>> fs/gfs2/file.c:948:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     948 | static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
         | ^~~~~~
>> fs/gfs2/file.c:1002:13: error: invalid storage class for function 'calc_max_reserv'
    1002 | static void calc_max_reserv(struct gfs2_inode *ip, loff_t *len,
         |             ^~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1024:13: error: invalid storage class for function '__gfs2_fallocate'
    1024 | static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
         |             ^~~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1140:13: error: invalid storage class for function 'gfs2_fallocate'
    1140 | static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
         |             ^~~~~~~~~~~~~~
>> fs/gfs2/file.c:1189:16: error: invalid storage class for function 'gfs2_file_splice_write'
    1189 | static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe,
         |                ^~~~~~~~~~~~~~~~~~~~~~
>> fs/gfs2/file.c:1393:1: error: expected declaration or statement at end of input
    1393 | };
         | ^
   fs/gfs2/file.c:1385:30: warning: unused variable 'gfs2_dir_fops_nolock' [-Wunused-variable]
    1385 | const struct file_operations gfs2_dir_fops_nolock = {
         |                              ^~~~~~~~~~~~~~~~~~~~
   fs/gfs2/file.c:1368:30: warning: unused variable 'gfs2_file_fops_nolock' [-Wunused-variable]
    1368 | const struct file_operations gfs2_file_fops_nolock = {
         |                              ^~~~~~~~~~~~~~~~~~~~~
   At top level:
   fs/gfs2/file.c:872:16: warning: 'gfs2_file_write_iter' defined but not used [-Wunused-function]
     872 | static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
         |                ^~~~~~~~~~~~~~~~~~~~


vim +/fallocate_chunk +948 fs/gfs2/file.c

56aa616a03feca Steven Whitehouse   2009-12-08   947  
2fe17c1075836b Christoph Hellwig   2011-01-14  @948  static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
2fe17c1075836b Christoph Hellwig   2011-01-14   949  			   int mode)
2fe17c1075836b Christoph Hellwig   2011-01-14   950  {
fffb64127adc3e Andreas Gruenbacher 2018-03-29   951  	struct super_block *sb = inode->i_sb;
2fe17c1075836b Christoph Hellwig   2011-01-14   952  	struct gfs2_inode *ip = GFS2_I(inode);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   953  	loff_t end = offset + len;
2fe17c1075836b Christoph Hellwig   2011-01-14   954  	struct buffer_head *dibh;
2fe17c1075836b Christoph Hellwig   2011-01-14   955  	int error;
2fe17c1075836b Christoph Hellwig   2011-01-14   956  
2fe17c1075836b Christoph Hellwig   2011-01-14   957  	error = gfs2_meta_inode_buffer(ip, &dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   958  	if (unlikely(error))
64dd153c83743a Benjamin Marzinski  2011-09-12   959  		return error;
2fe17c1075836b Christoph Hellwig   2011-01-14   960  
350a9b0a7269c6 Steven Whitehouse   2012-12-14   961  	gfs2_trans_add_meta(ip->i_gl, dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   962  
2fe17c1075836b Christoph Hellwig   2011-01-14   963  	if (gfs2_is_stuffed(ip)) {
2fe17c1075836b Christoph Hellwig   2011-01-14   964  		error = gfs2_unstuff_dinode(ip, NULL);
2fe17c1075836b Christoph Hellwig   2011-01-14   965  		if (unlikely(error))
2fe17c1075836b Christoph Hellwig   2011-01-14   966  			goto out;
2fe17c1075836b Christoph Hellwig   2011-01-14   967  	}
2fe17c1075836b Christoph Hellwig   2011-01-14   968  
fffb64127adc3e Andreas Gruenbacher 2018-03-29   969  	while (offset < end) {
c25892827c7996 Andreas Gruenbacher 2018-07-06   970  		struct iomap iomap = { };
c25892827c7996 Andreas Gruenbacher 2018-07-06   971  
54992257fe4bb9 Andreas Gruenbacher 2021-03-27   972  		error = gfs2_iomap_alloc(inode, offset, end - offset, &iomap);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   973  		if (error)
64dd153c83743a Benjamin Marzinski  2011-09-12   974  			goto out;
fffb64127adc3e Andreas Gruenbacher 2018-03-29   975  		offset = iomap.offset + iomap.length;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24   976  		if (!(iomap.flags & IOMAP_F_NEW))
64dd153c83743a Benjamin Marzinski  2011-09-12   977  			continue;
fffb64127adc3e Andreas Gruenbacher 2018-03-29   978  		error = sb_issue_zeroout(sb, iomap.addr >> inode->i_blkbits,
fffb64127adc3e Andreas Gruenbacher 2018-03-29   979  					 iomap.length >> inode->i_blkbits,
fffb64127adc3e Andreas Gruenbacher 2018-03-29   980  					 GFP_NOFS);
fffb64127adc3e Andreas Gruenbacher 2018-03-29   981  		if (error) {
fffb64127adc3e Andreas Gruenbacher 2018-03-29   982  			fs_err(GFS2_SB(inode), "Failed to zero data buffers\n");
2fe17c1075836b Christoph Hellwig   2011-01-14   983  			goto out;
2fe17c1075836b Christoph Hellwig   2011-01-14   984  		}
64dd153c83743a Benjamin Marzinski  2011-09-12   985  	}
2fe17c1075836b Christoph Hellwig   2011-01-14   986  out:
64dd153c83743a Benjamin Marzinski  2011-09-12   987  	brelse(dibh);
2fe17c1075836b Christoph Hellwig   2011-01-14   988  	return error;
2fe17c1075836b Christoph Hellwig   2011-01-14   989  }
f3b64b57c044fe Andreas Gruenbacher 2019-08-31   990  
d9be0cda774e7f Abhi Das            2015-03-18   991  /**
d9be0cda774e7f Abhi Das            2015-03-18   992   * calc_max_reserv() - Reverse of write_calc_reserv. Given a number of
d9be0cda774e7f Abhi Das            2015-03-18   993   *                     blocks, determine how many bytes can be written.
d9be0cda774e7f Abhi Das            2015-03-18   994   * @ip:          The inode in question.
d9be0cda774e7f Abhi Das            2015-03-18   995   * @len:         Max cap of bytes. What we return in *len must be <= this.
d9be0cda774e7f Abhi Das            2015-03-18   996   * @data_blocks: Compute and return the number of data blocks needed
d9be0cda774e7f Abhi Das            2015-03-18   997   * @ind_blocks:  Compute and return the number of indirect blocks needed
d9be0cda774e7f Abhi Das            2015-03-18   998   * @max_blocks:  The total blocks available to work with.
d9be0cda774e7f Abhi Das            2015-03-18   999   *
d9be0cda774e7f Abhi Das            2015-03-18  1000   * Returns: void, but @len, @data_blocks and @ind_blocks are filled in.
d9be0cda774e7f Abhi Das            2015-03-18  1001   */
d9be0cda774e7f Abhi Das            2015-03-18 @1002  static void calc_max_reserv(struct gfs2_inode *ip, loff_t *len,
d9be0cda774e7f Abhi Das            2015-03-18  1003  			    unsigned int *data_blocks, unsigned int *ind_blocks,
d9be0cda774e7f Abhi Das            2015-03-18  1004  			    unsigned int max_blocks)
2fe17c1075836b Christoph Hellwig   2011-01-14  1005  {
d9be0cda774e7f Abhi Das            2015-03-18  1006  	loff_t max = *len;
2fe17c1075836b Christoph Hellwig   2011-01-14  1007  	const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1008  	unsigned int tmp, max_data = max_blocks - 3 * (sdp->sd_max_height - 1);
2fe17c1075836b Christoph Hellwig   2011-01-14  1009  
2fe17c1075836b Christoph Hellwig   2011-01-14  1010  	for (tmp = max_data; tmp > sdp->sd_diptrs;) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1011  		tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
2fe17c1075836b Christoph Hellwig   2011-01-14  1012  		max_data -= tmp;
2fe17c1075836b Christoph Hellwig   2011-01-14  1013  	}
d9be0cda774e7f Abhi Das            2015-03-18  1014  
2fe17c1075836b Christoph Hellwig   2011-01-14  1015  	*data_blocks = max_data;
2fe17c1075836b Christoph Hellwig   2011-01-14  1016  	*ind_blocks = max_blocks - max_data;
2fe17c1075836b Christoph Hellwig   2011-01-14  1017  	*len = ((loff_t)max_data - 3) << sdp->sd_sb.sb_bsize_shift;
2fe17c1075836b Christoph Hellwig   2011-01-14  1018  	if (*len > max) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1019  		*len = max;
2fe17c1075836b Christoph Hellwig   2011-01-14  1020  		gfs2_write_calc_reserv(ip, max, data_blocks, ind_blocks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1021  	}
2fe17c1075836b Christoph Hellwig   2011-01-14  1022  }
2fe17c1075836b Christoph Hellwig   2011-01-14  1023  
9c9f1159a54c61 Andrew Price        2014-11-12 @1024  static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
2fe17c1075836b Christoph Hellwig   2011-01-14  1025  {
496ad9aa8ef448 Al Viro             2013-01-23  1026  	struct inode *inode = file_inode(file);
2fe17c1075836b Christoph Hellwig   2011-01-14  1027  	struct gfs2_sbd *sdp = GFS2_SB(inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1028  	struct gfs2_inode *ip = GFS2_I(inode);
7b9cff467144c8 Steven Whitehouse   2013-10-02  1029  	struct gfs2_alloc_parms ap = { .aflags = 0, };
2fe17c1075836b Christoph Hellwig   2011-01-14  1030  	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1031  	loff_t bytes, max_bytes, max_blks;
2fe17c1075836b Christoph Hellwig   2011-01-14  1032  	int error;
4442f2e03ed964 Steven Whitehouse   2011-11-21  1033  	const loff_t pos = offset;
4442f2e03ed964 Steven Whitehouse   2011-11-21  1034  	const loff_t count = len;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1035  	loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
2fe17c1075836b Christoph Hellwig   2011-01-14  1036  	loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
64dd153c83743a Benjamin Marzinski  2011-09-12  1037  	loff_t max_chunk_size = UINT_MAX & bsize_mask;
a0846a534c5fbc Bob Peterson        2014-02-06  1038  
2fe17c1075836b Christoph Hellwig   2011-01-14  1039  	next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
2fe17c1075836b Christoph Hellwig   2011-01-14  1040  
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1041  	offset &= bsize_mask;
2fe17c1075836b Christoph Hellwig   2011-01-14  1042  
2fe17c1075836b Christoph Hellwig   2011-01-14  1043  	len = next - offset;
2fe17c1075836b Christoph Hellwig   2011-01-14  1044  	bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2;
2fe17c1075836b Christoph Hellwig   2011-01-14  1045  	if (!bytes)
2fe17c1075836b Christoph Hellwig   2011-01-14  1046  		bytes = UINT_MAX;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1047  	bytes &= bsize_mask;
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1048  	if (bytes == 0)
6905d9e4dda611 Benjamin Marzinski  2011-04-26  1049  		bytes = sdp->sd_sb.sb_bsize;
2fe17c1075836b Christoph Hellwig   2011-01-14  1050  
da1dfb6af849cb Steven Whitehouse   2012-07-26  1051  	gfs2_size_hint(file, offset, len);
8e2e00473598dd Bob Peterson        2012-07-19  1052  
d9be0cda774e7f Abhi Das            2015-03-18  1053  	gfs2_write_calc_reserv(ip, PAGE_SIZE, &data_blocks, &ind_blocks);
d9be0cda774e7f Abhi Das            2015-03-18  1054  	ap.min_target = data_blocks + ind_blocks;
d9be0cda774e7f Abhi Das            2015-03-18  1055  
2fe17c1075836b Christoph Hellwig   2011-01-14  1056  	while (len > 0) {
2fe17c1075836b Christoph Hellwig   2011-01-14  1057  		if (len < bytes)
2fe17c1075836b Christoph Hellwig   2011-01-14  1058  			bytes = len;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1059  		if (!gfs2_write_alloc_required(ip, offset, bytes)) {
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1060  			len -= bytes;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1061  			offset += bytes;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1062  			continue;
58a7d5fb8e3127 Benjamin Marzinski  2012-03-08  1063  		}
d9be0cda774e7f Abhi Das            2015-03-18  1064  
d9be0cda774e7f Abhi Das            2015-03-18  1065  		/* We need to determine how many bytes we can actually
d9be0cda774e7f Abhi Das            2015-03-18  1066  		 * fallocate without exceeding quota or going over the
d9be0cda774e7f Abhi Das            2015-03-18  1067  		 * end of the fs. We start off optimistically by assuming
d9be0cda774e7f Abhi Das            2015-03-18  1068  		 * we can write max_bytes */
d9be0cda774e7f Abhi Das            2015-03-18  1069  		max_bytes = (len > max_chunk_size) ? max_chunk_size : len;
d9be0cda774e7f Abhi Das            2015-03-18  1070  
d9be0cda774e7f Abhi Das            2015-03-18  1071  		/* Since max_bytes is most likely a theoretical max, we
d9be0cda774e7f Abhi Das            2015-03-18  1072  		 * calculate a more realistic 'bytes' to serve as a good
d9be0cda774e7f Abhi Das            2015-03-18  1073  		 * starting point for the number of bytes we may be able
d9be0cda774e7f Abhi Das            2015-03-18  1074  		 * to write */
2fe17c1075836b Christoph Hellwig   2011-01-14  1075  		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
7b9cff467144c8 Steven Whitehouse   2013-10-02  1076  		ap.target = data_blocks + ind_blocks;
b8fbf471edb3db Abhi Das            2015-03-18  1077  
b8fbf471edb3db Abhi Das            2015-03-18  1078  		error = gfs2_quota_lock_check(ip, &ap);
2fe17c1075836b Christoph Hellwig   2011-01-14  1079  		if (error)
9c9f1159a54c61 Andrew Price        2014-11-12  1080  			return error;
d9be0cda774e7f Abhi Das            2015-03-18  1081  		/* ap.allowed tells us how many blocks quota will allow
d9be0cda774e7f Abhi Das            2015-03-18  1082  		 * us to write. Check if this reduces max_blks */
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1083  		max_blks = UINT_MAX;
174d1232ebc84f Andreas Gruenbacher 2018-02-20  1084  		if (ap.allowed)
d9be0cda774e7f Abhi Das            2015-03-18  1085  			max_blks = ap.allowed;
2fe17c1075836b Christoph Hellwig   2011-01-14  1086  
7b9cff467144c8 Steven Whitehouse   2013-10-02  1087  		error = gfs2_inplace_reserve(ip, &ap);
d9be0cda774e7f Abhi Das            2015-03-18  1088  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1089  			goto out_qunlock;
d9be0cda774e7f Abhi Das            2015-03-18  1090  
d9be0cda774e7f Abhi Das            2015-03-18  1091  		/* check if the selected rgrp limits our max_blks further */
725d0e9d464d56 Andreas Gruenbacher 2018-10-02  1092  		if (ip->i_res.rs_reserved < max_blks)
725d0e9d464d56 Andreas Gruenbacher 2018-10-02  1093  			max_blks = ip->i_res.rs_reserved;
d9be0cda774e7f Abhi Das            2015-03-18  1094  
d9be0cda774e7f Abhi Das            2015-03-18  1095  		/* Almost done. Calculate bytes that can be written using
d9be0cda774e7f Abhi Das            2015-03-18  1096  		 * max_blks. We also recompute max_bytes, data_blocks and
d9be0cda774e7f Abhi Das            2015-03-18  1097  		 * ind_blocks */
d9be0cda774e7f Abhi Das            2015-03-18  1098  		calc_max_reserv(ip, &max_bytes, &data_blocks,
d9be0cda774e7f Abhi Das            2015-03-18  1099  				&ind_blocks, max_blks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1100  
2fe17c1075836b Christoph Hellwig   2011-01-14  1101  		rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA +
71f890f7f758f3 Steven Whitehouse   2012-07-30  1102  			  RES_RG_HDR + gfs2_rg_blocks(ip, data_blocks + ind_blocks);
2fe17c1075836b Christoph Hellwig   2011-01-14  1103  		if (gfs2_is_jdata(ip))
2fe17c1075836b Christoph Hellwig   2011-01-14  1104  			rblocks += data_blocks ? data_blocks : 1;
2fe17c1075836b Christoph Hellwig   2011-01-14  1105  
2fe17c1075836b Christoph Hellwig   2011-01-14  1106  		error = gfs2_trans_begin(sdp, rblocks,
45eb05042d5667 Andreas Gruenbacher 2019-09-02  1107  					 PAGE_SIZE >> inode->i_blkbits);
2fe17c1075836b Christoph Hellwig   2011-01-14  1108  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1109  			goto out_trans_fail;
2fe17c1075836b Christoph Hellwig   2011-01-14  1110  
2fe17c1075836b Christoph Hellwig   2011-01-14  1111  		error = fallocate_chunk(inode, offset, max_bytes, mode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1112  		gfs2_trans_end(sdp);
2fe17c1075836b Christoph Hellwig   2011-01-14  1113  
2fe17c1075836b Christoph Hellwig   2011-01-14  1114  		if (error)
2fe17c1075836b Christoph Hellwig   2011-01-14  1115  			goto out_trans_fail;
2fe17c1075836b Christoph Hellwig   2011-01-14  1116  
2fe17c1075836b Christoph Hellwig   2011-01-14  1117  		len -= max_bytes;
2fe17c1075836b Christoph Hellwig   2011-01-14  1118  		offset += max_bytes;
2fe17c1075836b Christoph Hellwig   2011-01-14  1119  		gfs2_inplace_release(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1120  		gfs2_quota_unlock(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1121  	}
4442f2e03ed964 Steven Whitehouse   2011-11-21  1122  
0a6a4abc84668d Andreas Gruenbacher 2019-08-08  1123  	if (!(mode & FALLOC_FL_KEEP_SIZE) && (pos + count) > inode->i_size)
1885867b84d58e Andrew Price        2014-11-12  1124  		i_size_write(inode, pos + count);
98f1a696a1b2f6 Andrew Price        2014-11-12  1125  	file_update_time(file);
4b813f09405823 Andrew Price        2015-09-22  1126  	mark_inode_dirty(inode);
1885867b84d58e Andrew Price        2014-11-12  1127  
dde0c2e7984829 Christoph Hellwig   2016-04-07  1128  	if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
dde0c2e7984829 Christoph Hellwig   2016-04-07  1129  		return vfs_fsync_range(file, pos, pos + count - 1,
dde0c2e7984829 Christoph Hellwig   2016-04-07  1130  			       (file->f_flags & __O_SYNC) ? 0 : 1);
dde0c2e7984829 Christoph Hellwig   2016-04-07  1131  	return 0;
2fe17c1075836b Christoph Hellwig   2011-01-14  1132  
2fe17c1075836b Christoph Hellwig   2011-01-14  1133  out_trans_fail:
2fe17c1075836b Christoph Hellwig   2011-01-14  1134  	gfs2_inplace_release(ip);
2fe17c1075836b Christoph Hellwig   2011-01-14  1135  out_qunlock:
2fe17c1075836b Christoph Hellwig   2011-01-14  1136  	gfs2_quota_unlock(ip);
9c9f1159a54c61 Andrew Price        2014-11-12  1137  	return error;
9c9f1159a54c61 Andrew Price        2014-11-12  1138  }
9c9f1159a54c61 Andrew Price        2014-11-12  1139  
9c9f1159a54c61 Andrew Price        2014-11-12 @1140  static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
9c9f1159a54c61 Andrew Price        2014-11-12  1141  {
9c9f1159a54c61 Andrew Price        2014-11-12  1142  	struct inode *inode = file_inode(file);
d4d7fc12b642a1 Andrew Price        2017-04-05  1143  	struct gfs2_sbd *sdp = GFS2_SB(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1144  	struct gfs2_inode *ip = GFS2_I(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1145  	struct gfs2_holder gh;
9c9f1159a54c61 Andrew Price        2014-11-12  1146  	int ret;
9c9f1159a54c61 Andrew Price        2014-11-12  1147  
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1148  	if (mode & ~(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE))
d4d7fc12b642a1 Andrew Price        2017-04-05  1149  		return -EOPNOTSUPP;
d4d7fc12b642a1 Andrew Price        2017-04-05  1150  	/* fallocate is needed by gfs2_grow to reserve space in the rindex */
d4d7fc12b642a1 Andrew Price        2017-04-05  1151  	if (gfs2_is_jdata(ip) && inode != sdp->sd_rindex)
9c9f1159a54c61 Andrew Price        2014-11-12  1152  		return -EOPNOTSUPP;
9c9f1159a54c61 Andrew Price        2014-11-12  1153  
5955102c9984fa Al Viro             2016-01-22  1154  	inode_lock(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1155  
9c9f1159a54c61 Andrew Price        2014-11-12  1156  	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
9c9f1159a54c61 Andrew Price        2014-11-12  1157  	ret = gfs2_glock_nq(&gh);
9c9f1159a54c61 Andrew Price        2014-11-12  1158  	if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1159  		goto out_uninit;
9c9f1159a54c61 Andrew Price        2014-11-12  1160  
9c9f1159a54c61 Andrew Price        2014-11-12  1161  	if (!(mode & FALLOC_FL_KEEP_SIZE) &&
9c9f1159a54c61 Andrew Price        2014-11-12  1162  	    (offset + len) > inode->i_size) {
9c9f1159a54c61 Andrew Price        2014-11-12  1163  		ret = inode_newsize_ok(inode, offset + len);
9c9f1159a54c61 Andrew Price        2014-11-12  1164  		if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1165  			goto out_unlock;
9c9f1159a54c61 Andrew Price        2014-11-12  1166  	}
9c9f1159a54c61 Andrew Price        2014-11-12  1167  
9c9f1159a54c61 Andrew Price        2014-11-12  1168  	ret = get_write_access(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1169  	if (ret)
9c9f1159a54c61 Andrew Price        2014-11-12  1170  		goto out_unlock;
9c9f1159a54c61 Andrew Price        2014-11-12  1171  
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1172  	if (mode & FALLOC_FL_PUNCH_HOLE) {
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1173  		ret = __gfs2_punch_hole(file, offset, len);
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1174  	} else {
9c9f1159a54c61 Andrew Price        2014-11-12  1175  		ret = __gfs2_fallocate(file, mode, offset, len);
9c9f1159a54c61 Andrew Price        2014-11-12  1176  		if (ret)
a097dc7e24cba7 Bob Peterson        2015-07-16  1177  			gfs2_rs_deltree(&ip->i_res);
4e56a6411fbce6 Andreas Gruenbacher 2017-12-14  1178  	}
a097dc7e24cba7 Bob Peterson        2015-07-16  1179  
9c9f1159a54c61 Andrew Price        2014-11-12  1180  	put_write_access(inode);
2fe17c1075836b Christoph Hellwig   2011-01-14  1181  out_unlock:
a0846a534c5fbc Bob Peterson        2014-02-06  1182  	gfs2_glock_dq(&gh);
2fe17c1075836b Christoph Hellwig   2011-01-14  1183  out_uninit:
a0846a534c5fbc Bob Peterson        2014-02-06  1184  	gfs2_holder_uninit(&gh);
5955102c9984fa Al Viro             2016-01-22  1185  	inode_unlock(inode);
9c9f1159a54c61 Andrew Price        2014-11-12  1186  	return ret;
2fe17c1075836b Christoph Hellwig   2011-01-14  1187  }
2fe17c1075836b Christoph Hellwig   2011-01-14  1188  

:::::: The code at line 948 was first introduced by commit
:::::: 2fe17c1075836b66678ed2a305fd09b6773883aa fallocate should be a file operation

:::::: TO: Christoph Hellwig <hch@lst.de>
:::::: CC: Al Viro <viro@zeniv.linux.org.uk>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 25865 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20210512/e0b823ec/attachment.gz>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-11 18:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-11 18:42 [Cluster-devel] [gfs2:for-next 1/2] fs/gfs2/file.c:948:12: error: invalid storage class for function 'fallocate_chunk' kernel test robot
2021-05-11 18:42 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-05-11 18:46 [Cluster-devel] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.