All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [sashal-linux-stable:queue-5.4 116/132] fs/btrfs/inode.c:10982:7: error: implicit declaration of function 'btrfs_drew_try_write_lock'
Date: Sat, 20 Mar 2021 12:10:18 +0800	[thread overview]
Message-ID: <202103201211.JWVDdLCh-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 10934 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git queue-5.4
head:   d2c5af89e80c5b71f1da59879464a930947306a2
commit: 5f6e061c42f11262ce5b8065b50d90aaa970939b [116/132] btrfs: fix race between swap file activation and snapshot creation
config: x86_64-randconfig-r033-20210318 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 436c6c9c20cc522c92a923440a5fc509c342a7db)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git/commit/?id=5f6e061c42f11262ce5b8065b50d90aaa970939b
        git remote add sashal-linux-stable https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git
        git fetch --no-tags sashal-linux-stable queue-5.4
        git checkout 5f6e061c42f11262ce5b8065b50d90aaa970939b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All errors (new ones prefixed by >>):

>> fs/btrfs/inode.c:10982:7: error: implicit declaration of function 'btrfs_drew_try_write_lock' [-Werror,-Wimplicit-function-declaration]
           if (!btrfs_drew_try_write_lock(&root->snapshot_lock)) {
                ^
   fs/btrfs/inode.c:10982:7: note: did you mean 'btrfs_try_tree_write_lock'?
   fs/btrfs/locking.h:24:5: note: 'btrfs_try_tree_write_lock' declared here
   int btrfs_try_tree_write_lock(struct extent_buffer *eb);
       ^
>> fs/btrfs/inode.c:10982:40: error: no member named 'snapshot_lock' in 'struct btrfs_root'
           if (!btrfs_drew_try_write_lock(&root->snapshot_lock)) {
                                           ~~~~  ^
>> fs/btrfs/inode.c:11129:2: error: implicit declaration of function 'btrfs_drew_write_unlock' [-Werror,-Wimplicit-function-declaration]
           btrfs_drew_write_unlock(&root->snapshot_lock);
           ^
   fs/btrfs/inode.c:11129:33: error: no member named 'snapshot_lock' in 'struct btrfs_root'
           btrfs_drew_write_unlock(&root->snapshot_lock);
                                    ~~~~  ^
   4 errors generated.


vim +/btrfs_drew_try_write_lock +10982 fs/btrfs/inode.c

 10917	
 10918	static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
 10919				       sector_t *span)
 10920	{
 10921		struct inode *inode = file_inode(file);
 10922		struct btrfs_root *root = BTRFS_I(inode)->root;
 10923		struct btrfs_fs_info *fs_info = root->fs_info;
 10924		struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
 10925		struct extent_state *cached_state = NULL;
 10926		struct extent_map *em = NULL;
 10927		struct btrfs_device *device = NULL;
 10928		struct btrfs_swap_info bsi = {
 10929			.lowest_ppage = (sector_t)-1ULL,
 10930		};
 10931		int ret = 0;
 10932		u64 isize;
 10933		u64 start;
 10934	
 10935		/*
 10936		 * If the swap file was just created, make sure delalloc is done. If the
 10937		 * file changes again after this, the user is doing something stupid and
 10938		 * we don't really care.
 10939		 */
 10940		ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
 10941		if (ret)
 10942			return ret;
 10943	
 10944		/*
 10945		 * The inode is locked, so these flags won't change after we check them.
 10946		 */
 10947		if (BTRFS_I(inode)->flags & BTRFS_INODE_COMPRESS) {
 10948			btrfs_warn(fs_info, "swapfile must not be compressed");
 10949			return -EINVAL;
 10950		}
 10951		if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW)) {
 10952			btrfs_warn(fs_info, "swapfile must not be copy-on-write");
 10953			return -EINVAL;
 10954		}
 10955		if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
 10956			btrfs_warn(fs_info, "swapfile must not be checksummed");
 10957			return -EINVAL;
 10958		}
 10959	
 10960		/*
 10961		 * Balance or device remove/replace/resize can move stuff around from
 10962		 * under us. The exclop protection makes sure they aren't running/won't
 10963		 * run concurrently while we are mapping the swap extents, and
 10964		 * fs_info->swapfile_pins prevents them from running while the swap
 10965		 * file is active and moving the extents. Note that this also prevents
 10966		 * a concurrent device add which isn't actually necessary, but it's not
 10967		 * really worth the trouble to allow it.
 10968		 */
 10969		if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_SWAP_ACTIVATE)) {
 10970			btrfs_warn(fs_info,
 10971		   "cannot activate swapfile while exclusive operation is running");
 10972			return -EBUSY;
 10973		}
 10974	
 10975		/*
 10976		 * Prevent snapshot creation while we are activating the swap file.
 10977		 * We do not want to race with snapshot creation. If snapshot creation
 10978		 * already started before we bumped nr_swapfiles from 0 to 1 and
 10979		 * completes before the first write into the swap file after it is
 10980		 * activated, than that write would fallback to COW.
 10981		 */
 10982		if (!btrfs_drew_try_write_lock(&root->snapshot_lock)) {
 10983			btrfs_exclop_finish(fs_info);
 10984			btrfs_warn(fs_info,
 10985		   "cannot activate swapfile because snapshot creation is in progress");
 10986			return -EINVAL;
 10987		}
 10988		/*
 10989		 * Snapshots can create extents which require COW even if NODATACOW is
 10990		 * set. We use this counter to prevent snapshots. We must increment it
 10991		 * before walking the extents because we don't want a concurrent
 10992		 * snapshot to run after we've already checked the extents.
 10993		 */
 10994		atomic_inc(&root->nr_swapfiles);
 10995	
 10996		isize = ALIGN_DOWN(inode->i_size, fs_info->sectorsize);
 10997	
 10998		lock_extent_bits(io_tree, 0, isize - 1, &cached_state);
 10999		start = 0;
 11000		while (start < isize) {
 11001			u64 logical_block_start, physical_block_start;
 11002			struct btrfs_block_group_cache *bg;
 11003			u64 len = isize - start;
 11004	
 11005			em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len, 0);
 11006			if (IS_ERR(em)) {
 11007				ret = PTR_ERR(em);
 11008				goto out;
 11009			}
 11010	
 11011			if (em->block_start == EXTENT_MAP_HOLE) {
 11012				btrfs_warn(fs_info, "swapfile must not have holes");
 11013				ret = -EINVAL;
 11014				goto out;
 11015			}
 11016			if (em->block_start == EXTENT_MAP_INLINE) {
 11017				/*
 11018				 * It's unlikely we'll ever actually find ourselves
 11019				 * here, as a file small enough to fit inline won't be
 11020				 * big enough to store more than the swap header, but in
 11021				 * case something changes in the future, let's catch it
 11022				 * here rather than later.
 11023				 */
 11024				btrfs_warn(fs_info, "swapfile must not be inline");
 11025				ret = -EINVAL;
 11026				goto out;
 11027			}
 11028			if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
 11029				btrfs_warn(fs_info, "swapfile must not be compressed");
 11030				ret = -EINVAL;
 11031				goto out;
 11032			}
 11033	
 11034			logical_block_start = em->block_start + (start - em->start);
 11035			len = min(len, em->len - (start - em->start));
 11036			free_extent_map(em);
 11037			em = NULL;
 11038	
 11039			ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL, true);
 11040			if (ret < 0) {
 11041				goto out;
 11042			} else if (ret) {
 11043				ret = 0;
 11044			} else {
 11045				btrfs_warn(fs_info,
 11046					   "swapfile must not be copy-on-write");
 11047				ret = -EINVAL;
 11048				goto out;
 11049			}
 11050	
 11051			em = btrfs_get_chunk_map(fs_info, logical_block_start, len);
 11052			if (IS_ERR(em)) {
 11053				ret = PTR_ERR(em);
 11054				goto out;
 11055			}
 11056	
 11057			if (em->map_lookup->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
 11058				btrfs_warn(fs_info,
 11059					   "swapfile must have single data profile");
 11060				ret = -EINVAL;
 11061				goto out;
 11062			}
 11063	
 11064			if (device == NULL) {
 11065				device = em->map_lookup->stripes[0].dev;
 11066				ret = btrfs_add_swapfile_pin(inode, device, false);
 11067				if (ret == 1)
 11068					ret = 0;
 11069				else if (ret)
 11070					goto out;
 11071			} else if (device != em->map_lookup->stripes[0].dev) {
 11072				btrfs_warn(fs_info, "swapfile must be on one device");
 11073				ret = -EINVAL;
 11074				goto out;
 11075			}
 11076	
 11077			physical_block_start = (em->map_lookup->stripes[0].physical +
 11078						(logical_block_start - em->start));
 11079			len = min(len, em->len - (logical_block_start - em->start));
 11080			free_extent_map(em);
 11081			em = NULL;
 11082	
 11083			bg = btrfs_lookup_block_group(fs_info, logical_block_start);
 11084			if (!bg) {
 11085				btrfs_warn(fs_info,
 11086				   "could not find block group containing swapfile");
 11087				ret = -EINVAL;
 11088				goto out;
 11089			}
 11090	
 11091			ret = btrfs_add_swapfile_pin(inode, bg, true);
 11092			if (ret) {
 11093				btrfs_put_block_group(bg);
 11094				if (ret == 1)
 11095					ret = 0;
 11096				else
 11097					goto out;
 11098			}
 11099	
 11100			if (bsi.block_len &&
 11101			    bsi.block_start + bsi.block_len == physical_block_start) {
 11102				bsi.block_len += len;
 11103			} else {
 11104				if (bsi.block_len) {
 11105					ret = btrfs_add_swap_extent(sis, &bsi);
 11106					if (ret)
 11107						goto out;
 11108				}
 11109				bsi.start = start;
 11110				bsi.block_start = physical_block_start;
 11111				bsi.block_len = len;
 11112			}
 11113	
 11114			start += len;
 11115		}
 11116	
 11117		if (bsi.block_len)
 11118			ret = btrfs_add_swap_extent(sis, &bsi);
 11119	
 11120	out:
 11121		if (!IS_ERR_OR_NULL(em))
 11122			free_extent_map(em);
 11123	
 11124		unlock_extent_cached(io_tree, 0, isize - 1, &cached_state);
 11125	
 11126		if (ret)
 11127			btrfs_swap_deactivate(file);
 11128	
 11129		btrfs_drew_write_unlock(&root->snapshot_lock);
 11130	
 11131		btrfs_exclop_finish(fs_info);
 11132	
 11133		if (ret)
 11134			return ret;
 11135	
 11136		if (device)
 11137			sis->bdev = device->bdev;
 11138		*span = bsi.highest_ppage - bsi.lowest_ppage + 1;
 11139		sis->max = bsi.nr_pages;
 11140		sis->pages = bsi.nr_pages - 1;
 11141		sis->highest_bit = bsi.nr_pages - 1;
 11142		return bsi.nr_extents;
 11143	}
 11144	#else
 11145	static void btrfs_swap_deactivate(struct file *file)
 11146	{
 11147	}
 11148	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32038 bytes --]

                 reply	other threads:[~2021-03-20  4:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202103201211.JWVDdLCh-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.