All of lore.kernel.org
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [jlayton:ceph-fscache-iter 40/77] fs/fscache/read_helper.c:271:30: warning: variable 'trailer' set but not used
Date: Sat, 30 May 2020 17:08:31 +0800	[thread overview]
Message-ID: <202005301729.fonQBbcc%lkp@intel.com> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git ceph-fscache-iter
head:   ce11bedb85675dee88f70d28fc09cb5bca59c73e
commit: d440750b58ab0ae1365a0d1276f27cac3a00bc19 [40/77] fscache: Add read helper
config: x86_64-randconfig-c002-20200529 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce (this is a W=1 build):
        git checkout d440750b58ab0ae1365a0d1276f27cac3a00bc19
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

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

All warnings (new ones prefixed by >>, old ones prefixed by <<):

fs/fscache/read_helper.c: In function 'fscache_read_helper':
>> fs/fscache/read_helper.c:271:30: warning: variable 'trailer' set but not used [-Wunused-but-set-variable]
271 |  pgoff_t eof, cursor, start, trailer = ULONG_MAX;
|                              ^~~~~~~

vim +/trailer +271 fs/fscache/read_helper.c

   233	
   234	/**
   235	 * fscache_read_helper - Helper to manage a read request
   236	 * @req: The initialised request structure to use
   237	 * @requested_page: Singular page to include (LOCKED_PAGE/FOR_WRITE)
   238	 * @pages: Unattached pages to include (PAGE_LIST)
   239	 * @primary_index: The index of the primary page (FOR_WRITE)
   240	 * @max_pages: The maximum number of pages to read in one transaction
   241	 * @type: FSCACHE_READ_*
   242	 * @aop_flags: AOP_FLAG_*
   243	 *
   244	 * Read a sequence of pages appropriately sized for an fscache allocation
   245	 * block.  Pages are added at both ends and to fill in the gaps as appropriate
   246	 * to make it the right size.
   247	 *
   248	 * req->mapping should indicate the mapping to which the pages will be attached.
   249	 *
   250	 * The operations pointed to by req->ops will be used to issue or reissue a
   251	 * read against the server in case the cache is unavailable, incomplete or
   252	 * generates an error.  req->iter will be set up to point to the iterator
   253	 * representing the buffer to be filled in.
   254	 *
   255	 * A ref on @req is consumed eventually by this function or one of its
   256	 * eventually-dispatched callees.
   257	 */
   258	static int fscache_read_helper(struct fscache_io_request *req,
   259				       struct page **requested_page,
   260				       struct list_head *pages,
   261				       pgoff_t primary_index,
   262				       pgoff_t max_pages,
   263				       enum fscache_read_type type,
   264				       unsigned int aop_flags)
   265	{
   266		struct fscache_extent extent;
   267		struct address_space *mapping = req->mapping;
   268		struct page *page;
   269		enum fscache_read_helper_trace what;
   270		unsigned int notes;
 > 271		pgoff_t eof, cursor, start, trailer = ULONG_MAX;
   272		loff_t i_size, new_size;
   273		int ret;
   274	
   275		extent.granularity = 1;
   276		extent.max_pages = max_pages;
   277		i_size = i_size_read(mapping->host);
   278	
   279		switch (type) {
   280		case FSCACHE_READ_PAGE_LIST:
   281			primary_index = lru_to_page(pages)->index;
   282			extent.start = primary_index;
   283			extent.end = lru_to_last_page(pages)->index + 1;
   284			break;
   285	
   286		case FSCACHE_READ_LOCKED_PAGE:
   287			primary_index = (*requested_page)->index;
   288			extent.start = primary_index;
   289			extent.end = primary_index + 1;
   290			break;
   291	
   292		case FSCACHE_READ_FOR_WRITE:
   293			new_size = (loff_t)(primary_index + 1) << PAGE_SHIFT;
   294			if (new_size > i_size)
   295				i_size = new_size;
   296			extent.start = primary_index;
   297			extent.end = primary_index + 1;
   298			break;
   299	
   300		default:
   301			BUG();
   302		}
   303	
   304		_enter("%lx,%x", primary_index, extent.max_pages);
   305	
   306		eof = (i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
   307	
   308		notes = fscache_shape_extent(req->cookie, &extent, i_size, false);
   309		req->dio_block_size = extent.dio_block_size;
   310	
   311		start = cursor = extent.start;
   312	
   313		/* Add pages to the pagecache.  We keep the pages ref'd and locked
   314		 * until the read is complete.  We may also need to add pages to both
   315		 * sides of the request to make it up to the cache allocation granule
   316		 * alignment and size.
   317		 *
   318		 * Note that it's possible for the file size to change whilst we're
   319		 * doing this, but we rely on the server returning less than we asked
   320		 * for if the file shrank.  We also rely on this to deal with a partial
   321		 * page at the end of the file.
   322		 *
   323		 * If we're going to end up loading from the server and writing to the
   324		 * cache, we start by inserting blank pages before the first page being
   325		 * examined.  If we can fetch from the cache or we're not going to
   326		 * write to the cache, it's unnecessary.
   327		 */
   328		if (notes & FSCACHE_RHLP_NOTE_WRITE_TO_CACHE) {
   329			req->write_to_cache = true;
   330			while (cursor < primary_index) {
   331				page = find_or_create_page(mapping, cursor,
   332							   readahead_gfp_mask(mapping));
   333				if (!page)
   334					goto nomem;
   335				if (!PageUptodate(page)) {
   336					req->nr_pages++; /* Add to the reading list */
   337					cursor++;
   338					continue;
   339				}
   340	
   341				/* There's an up-to-date page in the preface - just
   342				 * fetch the requested pages and skip saving to the
   343				 * cache.
   344				 */
   345				notes |= FSCACHE_RHLP_NOTE_U2D_IN_PREFACE;
   346				fscache_ignore_pages(mapping, start, cursor + 1);
   347				req->write_to_cache = false;
   348				start = cursor = primary_index;
   349				req->nr_pages = 0;
   350				break;
   351			}
   352			page = NULL;
   353		} else {
   354			req->write_to_cache = false;
   355			start = cursor = primary_index;
   356			req->nr_pages = 0;
   357		}
   358	
   359		switch (type) {
   360		case FSCACHE_READ_FOR_WRITE:
   361			/* We're doing a prefetch for a write on a single page.  We get
   362			 * or create the requested page if we weren't given it and lock
   363			 * it.
   364			 */
   365			notes |= FSCACHE_RHLP_NOTE_READ_FOR_WRITE;
   366			if (*requested_page) {
   367				_debug("prewrite req %lx", cursor);
   368				page = *requested_page;
   369				ret = -ERESTARTSYS;
   370				if (lock_page_killable(page) < 0)
   371					goto dont;
   372			} else {
   373				_debug("prewrite new %lx %lx", cursor, eof);
   374				page = grab_cache_page_write_begin(mapping, primary_index,
   375								   aop_flags);
   376				if (!page)
   377					goto nomem;
   378				*requested_page = page;
   379			}
   380			get_page(page);
   381			req->no_unlock_page = page;
   382			req->nr_pages++;
   383			cursor++;
   384			page = NULL;
   385			ret = 0;
   386			break;
   387	
   388		case FSCACHE_READ_LOCKED_PAGE:
   389			/* We've got a single page preattached to the inode and locked.
   390			 * Get our own ref on it.
   391			 */
   392			_debug("locked");
   393			notes |= FSCACHE_RHLP_NOTE_READ_LOCKED_PAGE;
   394			get_page(*requested_page);
   395			req->nr_pages++;
   396			cursor++;
   397			ret = 0;
   398			break;
   399	
   400		case FSCACHE_READ_PAGE_LIST:
   401			/* We've been given a contiguous list of pages to add. */
   402			notes |= FSCACHE_RHLP_NOTE_READ_PAGE_LIST;
   403			do {
   404				_debug("given %lx", cursor);
   405	
   406				page = lru_to_page(pages);
   407				if (page->index != cursor) {
   408					notes |= FSCACHE_RHLP_NOTE_LIST_NOTCONTIG;
   409					break;
   410				}
   411	
   412				list_del(&page->lru);
   413	
   414				ret = add_to_page_cache_lru(page, mapping, cursor,
   415							    readahead_gfp_mask(mapping));
   416				switch (ret) {
   417				case 0:
   418					/* Add to the reading list */
   419					req->nr_pages++;
   420					cursor++;
   421					page = NULL;
   422					break;
   423	
   424				case -EEXIST:
   425					put_page(page);
   426	
   427					_debug("conflict %lx %d", cursor, ret);
   428					page = find_or_create_page(mapping, cursor,
   429								   readahead_gfp_mask(mapping));
   430					if (!page) {
   431						notes |= FSCACHE_RHLP_NOTE_LIST_NOMEM;
   432						goto stop;
   433					}
   434	
   435					if (PageUptodate(page)) {
   436						unlock_page(page);
   437						put_page(page); /* Avoid overwriting */
   438						ret = 0;
   439						notes |= FSCACHE_RHLP_NOTE_LIST_U2D;
   440						goto stop;
   441					}
   442	
   443					req->nr_pages++; /* Add to the reading list */
   444					cursor++;
   445					break;
   446	
   447				default:
   448					_debug("add fail %lx %d", cursor, ret);
   449					put_page(page);
   450					page = NULL;
   451					notes |= FSCACHE_RHLP_NOTE_LIST_ERROR;
   452					goto stop;
   453				}
   454	
   455				/* Trim the fetch to the cache granularity so we don't
   456				 * get a chain-failure of blocks being unable to be
   457				 * used because the previous uncached read spilt over.
   458				 */
   459				if ((notes & FSCACHE_RHLP_NOTE_U2D_IN_PREFACE) &&
   460				    cursor == extent.start + extent.granularity)
   461					break;
   462	
   463			} while (!list_empty(pages) && req->nr_pages < extent.max_pages);
   464			ret = 0;
   465			break;
   466	
   467		default:
   468			BUG();
   469		}
   470	
   471		/* If we're going to be writing to the cache, insert pages after the
   472		 * requested block to make up the numbers.
   473		 */
   474		if (req->write_to_cache) {
   475			notes |= FSCACHE_RHLP_NOTE_TRAILER_ADD;
   476			trailer = cursor;
   477			while (req->nr_pages < extent.max_pages) {
   478				_debug("after %lx", cursor);
   479				page = find_or_create_page(mapping, cursor,
   480							   readahead_gfp_mask(mapping));
   481				if (!page) {
   482					notes |= FSCACHE_RHLP_NOTE_TRAILER_NOMEM;
   483					goto stop;
   484				}
   485				if (PageUptodate(page)) {
   486					unlock_page(page);
   487					put_page(page); /* Avoid overwriting */
   488					notes |= FSCACHE_RHLP_NOTE_TRAILER_U2D;
   489					goto stop;
   490				}
   491	
   492				req->nr_pages++; /* Add to the reading list */
   493				cursor++;
   494			}
   495		}
   496	
   497	stop:
   498		_debug("have %u", req->nr_pages);
   499		if (req->nr_pages == 0)
   500			goto dont;
   501	
   502		if (cursor <= primary_index) {
   503			_debug("v.short");
   504			goto nomem_unlock; /* We wouldn't've included the first page */
   505		}
   506	
   507	submit_anyway:
   508		if (!req->write_to_cache &&
   509		    req->nr_pages < extent.max_pages) {
   510			/* The request is short of what we need to be able to cache the
   511			 * entire set of pages and the trailer, so trim it to cache
   512			 * granularity if we can without reducing it to nothing.
   513			 */
   514			unsigned int down_to = round_down(req->nr_pages, extent.granularity);
   515			_debug("short %u", down_to);
   516	
   517			notes |= FSCACHE_RHLP_NOTE_UNDERSIZED;
   518	
   519			if (down_to > 0) {
   520				fscache_ignore_pages(mapping, extent.start + down_to, cursor);
   521				req->nr_pages = down_to;
   522			} else {
   523				req->write_to_cache = false;
   524			}
   525		}
   526	
   527		req->len = req->nr_pages * PAGE_SIZE;
   528		req->pos = start;
   529		req->pos <<= PAGE_SHIFT;
   530	
   531		if (start >= eof) {
   532			notes |= FSCACHE_RHLP_NOTE_AFTER_EOF;
   533			what = fscache_read_helper_skip;
   534		} else if (notes & FSCACHE_RHLP_NOTE_FILL_WITH_ZERO) {
   535			what = fscache_read_helper_zero;
   536		} else if (notes & FSCACHE_RHLP_NOTE_READ_FROM_CACHE) {
   537			what = fscache_read_helper_read;
   538		} else {
   539			what = fscache_read_helper_download;
   540		}
   541	
   542		ret = 0;
   543		if (req->ops->is_req_valid) {
   544			/* Allow the netfs to decide if the request is still valid
   545			 * after all the pages are locked.
   546			 */
   547			ret = req->ops->is_req_valid(req);
   548			if (ret < 0)
   549				notes |= FSCACHE_RHLP_NOTE_CANCELLED;
   550		}
   551	
   552		trace_fscache_read_helper(req->cookie, start, start + req->nr_pages,
   553					  notes, what);
   554	
   555		if (notes & FSCACHE_RHLP_NOTE_CANCELLED)
   556			goto cancelled;
   557	
   558		switch (what) {
   559		case fscache_read_helper_skip:
   560			/* The read is entirely beyond the end of the file, so skip the
   561			 * actual operation and let the done handler deal with clearing
   562			 * the pages.
   563			 */
   564			_debug("SKIP READ: %llu", req->len);
   565			fscache_read_done(req);
   566			break;
   567		case fscache_read_helper_zero:
   568			_debug("ZERO READ: %llu", req->len);
   569			fscache_read_done(req);
   570			break;
   571		case fscache_read_helper_read:
   572			req->io_done = fscache_file_read_maybe_reissue;
   573			fscache_read_from_cache(req);
   574			break;
   575		case fscache_read_helper_download:
   576			_debug("DOWNLOAD: %llu", req->len);
   577			req->io_done = fscache_read_done;
   578			fscache_read_from_server(req);
   579			break;
   580		default:
   581			BUG();
   582		}
   583	
   584		_leave(" = 0");
   585		return 0;
   586	
   587	nomem:
   588		if (cursor > primary_index)
   589			goto submit_anyway;
   590	nomem_unlock:
   591		ret = -ENOMEM;
   592	cancelled:
   593		fscache_ignore_pages(mapping, start, cursor);
   594	dont:
   595		_leave(" = %d", ret);
   596		return ret;
   597	}
   598	

---
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: 35711 bytes --]

                 reply	other threads:[~2020-05-30  9:08 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=202005301729.fonQBbcc%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.