Re: [ceph-client:wip-fscrypt 53/64] fs/ceph/file.c:1896 ceph_sync_write() error: uninitialized symbol 'assert_ver'.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2022-05-24 at 21:39 +0300, Dan Carpenter wrote:
> tree:   https://github.com/ceph/ceph-client.git wip-fscrypt
> head:   9ab30a676da19ce5d83364306a03d643dd446aca
> commit: 6341655663fe166fd30acca6b4e692d2fafb02e5 [53/64] ceph: add read/modify/write to ceph_sync_write
> config: microblaze-randconfig-m031-20220524 (https://download.01.org/0day-ci/archive/20220525/202205250038.pULlmpTX-lkp@xxxxxxxxx/config)
> compiler: microblaze-linux-gcc (GCC) 11.3.0
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> 
> New smatch warnings:
> fs/ceph/file.c:1896 ceph_sync_write() error: uninitialized symbol 'assert_ver'.
> 
> Old smatch warnings:
> fs/ceph/file.c:146 iter_get_bvecs_alloc() warn: Please consider using kvcalloc instead of kvmalloc_array
> 
> vim +/assert_ver +1896 fs/ceph/file.c
> 
> 06fee30f6a31f10 Yan, Zheng         2014-07-28  1550  static ssize_t
> 5dda377cf0a6bd4 Yan, Zheng         2015-04-30  1551  ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
> 5dda377cf0a6bd4 Yan, Zheng         2015-04-30  1552  		struct ceph_snap_context *snapc)
> e8344e668915a74 majianpeng         2013-09-12  1553  {
> e8344e668915a74 majianpeng         2013-09-12  1554  	struct file *file = iocb->ki_filp;
> e8344e668915a74 majianpeng         2013-09-12  1555  	struct inode *inode = file_inode(file);
> e8344e668915a74 majianpeng         2013-09-12  1556  	struct ceph_inode_info *ci = ceph_inode(inode);
> e8344e668915a74 majianpeng         2013-09-12  1557  	struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
> 6341655663fe166 Jeff Layton        2021-01-27  1558  	struct ceph_osd_client *osdc = &fsc->client->osdc;
> e8344e668915a74 majianpeng         2013-09-12  1559  	struct ceph_osd_request *req;
> e8344e668915a74 majianpeng         2013-09-12  1560  	struct page **pages;
> e8344e668915a74 majianpeng         2013-09-12  1561  	u64 len;
> e8344e668915a74 majianpeng         2013-09-12  1562  	int num_pages;
> e8344e668915a74 majianpeng         2013-09-12  1563  	int written = 0;
> e8344e668915a74 majianpeng         2013-09-12  1564  	int ret;
> efb0ca765ac6f49 Yan, Zheng         2017-05-22  1565  	bool check_caps = false;
> fac02ddf910814c Arnd Bergmann      2018-07-13  1566  	struct timespec64 mtime = current_time(inode);
> 4908b822b300d2d Al Viro            2014-04-03  1567  	size_t count = iov_iter_count(from);
> e8344e668915a74 majianpeng         2013-09-12  1568  
> e8344e668915a74 majianpeng         2013-09-12  1569  	if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
> e8344e668915a74 majianpeng         2013-09-12  1570  		return -EROFS;
> e8344e668915a74 majianpeng         2013-09-12  1571  
> 1c0a9c2d9783604 Yan, Zheng         2017-08-16  1572  	dout("sync_write on file %p %lld~%u snapc %p seq %lld\n",
> 1c0a9c2d9783604 Yan, Zheng         2017-08-16  1573  	     file, pos, (unsigned)count, snapc, snapc->seq);
> e8344e668915a74 majianpeng         2013-09-12  1574  
> e450f4d1a5d633d zhengbin           2019-02-01  1575  	ret = filemap_write_and_wait_range(inode->i_mapping,
> e450f4d1a5d633d zhengbin           2019-02-01  1576  					   pos, pos + count - 1);
> e8344e668915a74 majianpeng         2013-09-12  1577  	if (ret < 0)
> e8344e668915a74 majianpeng         2013-09-12  1578  		return ret;
> e8344e668915a74 majianpeng         2013-09-12  1579  
> 400e1286c0ec3fd Jeff Layton        2021-12-07  1580  	ceph_fscache_invalidate(inode, false);
> e8344e668915a74 majianpeng         2013-09-12  1581  	ret = invalidate_inode_pages2_range(inode->i_mapping,
> 09cbfeaf1a5a67b Kirill A. Shutemov 2016-04-01  1582  					    pos >> PAGE_SHIFT,
> e450f4d1a5d633d zhengbin           2019-02-01  1583  					    (pos + count - 1) >> PAGE_SHIFT);
> e8344e668915a74 majianpeng         2013-09-12  1584  	if (ret < 0)
> e8344e668915a74 majianpeng         2013-09-12  1585  		dout("invalidate_inode_pages2_range returned %d\n", ret);
> e8344e668915a74 majianpeng         2013-09-12  1586  
> 4908b822b300d2d Al Viro            2014-04-03  1587  	while ((len = iov_iter_count(from)) > 0) {
> e8344e668915a74 majianpeng         2013-09-12  1588  		size_t left;
> e8344e668915a74 majianpeng         2013-09-12  1589  		int n;
> 6341655663fe166 Jeff Layton        2021-01-27  1590  		u64 write_pos = pos;
> 6341655663fe166 Jeff Layton        2021-01-27  1591  		u64 write_len = len;
> 6341655663fe166 Jeff Layton        2021-01-27  1592  		u64 objnum, objoff;
> 6341655663fe166 Jeff Layton        2021-01-27  1593  		u32 xlen;
> 6341655663fe166 Jeff Layton        2021-01-27  1594  		u64 assert_ver;
> 6341655663fe166 Jeff Layton        2021-01-27  1595  		bool rmw;
> 6341655663fe166 Jeff Layton        2021-01-27  1596  		bool first, last;
> 6341655663fe166 Jeff Layton        2021-01-27  1597  		struct iov_iter saved_iter = *from;
> 6341655663fe166 Jeff Layton        2021-01-27  1598  		size_t off;
> e8344e668915a74 majianpeng         2013-09-12  1599  
> 6341655663fe166 Jeff Layton        2021-01-27  1600  		ceph_fscrypt_adjust_off_and_len(inode, &write_pos, &write_len);
> 6341655663fe166 Jeff Layton        2021-01-27  1601  
> 6341655663fe166 Jeff Layton        2021-01-27  1602  		/* clamp the length to the end of first object */
> 6341655663fe166 Jeff Layton        2021-01-27  1603  		ceph_calc_file_object_mapping(&ci->i_layout, write_pos,
> 6341655663fe166 Jeff Layton        2021-01-27  1604  						write_len, &objnum, &objoff,
> 6341655663fe166 Jeff Layton        2021-01-27  1605  						&xlen);
> 6341655663fe166 Jeff Layton        2021-01-27  1606  		write_len = xlen;
> 6341655663fe166 Jeff Layton        2021-01-27  1607  
> 6341655663fe166 Jeff Layton        2021-01-27  1608  		/* adjust len downward if it goes beyond current object */
> 6341655663fe166 Jeff Layton        2021-01-27  1609  		if (pos + len > write_pos + write_len)
> 6341655663fe166 Jeff Layton        2021-01-27  1610  			len = write_pos + write_len - pos;
> 6341655663fe166 Jeff Layton        2021-01-27  1611  
> 6341655663fe166 Jeff Layton        2021-01-27  1612  		/*
> 6341655663fe166 Jeff Layton        2021-01-27  1613  		 * If we had to adjust the length or position to align with a
> 6341655663fe166 Jeff Layton        2021-01-27  1614  		 * crypto block, then we must do a read/modify/write cycle. We
> 6341655663fe166 Jeff Layton        2021-01-27  1615  		 * use a version assertion to redrive the thing if something
> 6341655663fe166 Jeff Layton        2021-01-27  1616  		 * changes in between.
> 6341655663fe166 Jeff Layton        2021-01-27  1617  		 */
> 6341655663fe166 Jeff Layton        2021-01-27  1618  		first = pos != write_pos;
> 6341655663fe166 Jeff Layton        2021-01-27  1619  		last = (pos + len) != (write_pos + write_len);
> 6341655663fe166 Jeff Layton        2021-01-27  1620  		rmw = first || last;
> 6341655663fe166 Jeff Layton        2021-01-27  1621  
> 6341655663fe166 Jeff Layton        2021-01-27  1622  		dout("sync_write ino %llx %lld~%llu adjusted %lld~%llu -- %srmw\n",
> 6341655663fe166 Jeff Layton        2021-01-27  1623  		     ci->i_vino.ino, pos, len, write_pos, write_len, rmw ? "" : "no ");
> 6341655663fe166 Jeff Layton        2021-01-27  1624  
> 6341655663fe166 Jeff Layton        2021-01-27  1625  		/*
> 6341655663fe166 Jeff Layton        2021-01-27  1626  		 * The data is emplaced into the page as it would be if it were in
> 6341655663fe166 Jeff Layton        2021-01-27  1627  		 * an array of pagecache pages.
> 6341655663fe166 Jeff Layton        2021-01-27  1628  		 */
> 6341655663fe166 Jeff Layton        2021-01-27  1629  		num_pages = calc_pages_for(write_pos, write_len);
> 6341655663fe166 Jeff Layton        2021-01-27  1630  		pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
> 6341655663fe166 Jeff Layton        2021-01-27  1631  		if (IS_ERR(pages)) {
> 6341655663fe166 Jeff Layton        2021-01-27  1632  			ret = PTR_ERR(pages);
> 6341655663fe166 Jeff Layton        2021-01-27  1633  			break;
> 6341655663fe166 Jeff Layton        2021-01-27  1634  		}
> 6341655663fe166 Jeff Layton        2021-01-27  1635  
> 6341655663fe166 Jeff Layton        2021-01-27  1636  		/* Do we need to preload the pages? */
> 6341655663fe166 Jeff Layton        2021-01-27  1637  		if (rmw) {
> 
> "assert_ver" is only initialized when "rmw" is true.
> 

Fixed in tree by just initializing assert_ver to 0 during declaration.
That should ensure that it's always 0 unless it has been set to
something else.

Thanks, Dan!
-- 
Jeff Layton <jlayton@xxxxxxxxxx>




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux