All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/buffer: Remove redundant assignment to err
@ 2023-03-22  6:59 Jiapeng Chong
  2023-03-22  8:20 ` Christian Brauner
  2023-03-22 11:07 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Jiapeng Chong @ 2023-03-22  6:59 UTC (permalink / raw)
  To: viro; +Cc: brauner, linux-fsdevel, linux-kernel, Jiapeng Chong, Abaci Robot

Variable 'err' set but not used.

fs/buffer.c:2613:2: warning: Value stored to 'err' is never read.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4589
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 fs/buffer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index d759b105c1e7..c844b5b93a89 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2580,7 +2580,7 @@ int block_truncate_page(struct address_space *mapping,
 	struct inode *inode = mapping->host;
 	struct page *page;
 	struct buffer_head *bh;
-	int err;
+	int err = 0;
 
 	blocksize = i_blocksize(inode);
 	length = offset & (blocksize - 1);
@@ -2593,9 +2593,8 @@ int block_truncate_page(struct address_space *mapping,
 	iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits);
 	
 	page = grab_cache_page(mapping, index);
-	err = -ENOMEM;
 	if (!page)
-		goto out;
+		return -ENOMEM;
 
 	if (!page_has_buffers(page))
 		create_empty_buffers(page, blocksize, 0);
@@ -2609,7 +2608,6 @@ int block_truncate_page(struct address_space *mapping,
 		pos += blocksize;
 	}
 
-	err = 0;
 	if (!buffer_mapped(bh)) {
 		WARN_ON(bh->b_size != blocksize);
 		err = get_block(inode, iblock, bh, 0);
@@ -2633,7 +2631,6 @@ int block_truncate_page(struct address_space *mapping,
 
 	zero_user(page, offset, length);
 	mark_buffer_dirty(bh);
-	err = 0;
 
 unlock:
 	unlock_page(page);
-- 
2.20.1.7.g153144c


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

* Re: [PATCH] fs/buffer: Remove redundant assignment to err
  2023-03-22  6:59 [PATCH] fs/buffer: Remove redundant assignment to err Jiapeng Chong
@ 2023-03-22  8:20 ` Christian Brauner
  2023-03-22 11:07 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2023-03-22  8:20 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: viro, linux-fsdevel, linux-kernel, Abaci Robot

On Wed, Mar 22, 2023 at 02:59:49PM +0800, Jiapeng Chong wrote:
> Variable 'err' set but not used.
> 
> fs/buffer.c:2613:2: warning: Value stored to 'err' is never read.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4589
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  fs/buffer.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index d759b105c1e7..c844b5b93a89 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -2580,7 +2580,7 @@ int block_truncate_page(struct address_space *mapping,
>  	struct inode *inode = mapping->host;
>  	struct page *page;
>  	struct buffer_head *bh;
> -	int err;
> +	int err = 0;
>  
>  	blocksize = i_blocksize(inode);
>  	length = offset & (blocksize - 1);
> @@ -2593,9 +2593,8 @@ int block_truncate_page(struct address_space *mapping,
>  	iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits);
>  	
>  	page = grab_cache_page(mapping, index);
> -	err = -ENOMEM;
>  	if (!page)
> -		goto out;
> +		return -ENOMEM;

This change makes the out: label unused.

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

* Re: [PATCH] fs/buffer: Remove redundant assignment to err
  2023-03-22  6:59 [PATCH] fs/buffer: Remove redundant assignment to err Jiapeng Chong
  2023-03-22  8:20 ` Christian Brauner
@ 2023-03-22 11:07 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-03-22 11:07 UTC (permalink / raw)
  To: Jiapeng Chong, viro
  Cc: llvm, oe-kbuild-all, brauner, linux-fsdevel, linux-kernel,
	Jiapeng Chong, Abaci Robot

Hi Jiapeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on vfs-idmapping/for-next]
[also build test WARNING on linus/master v6.3-rc3 next-20230322]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jiapeng-Chong/fs-buffer-Remove-redundant-assignment-to-err/20230322-150022
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git for-next
patch link:    https://lore.kernel.org/r/20230322065949.29223-1-jiapeng.chong%40linux.alibaba.com
patch subject: [PATCH] fs/buffer: Remove redundant assignment to err
config: hexagon-randconfig-r036-20230322 (https://download.01.org/0day-ci/archive/20230322/202303221812.QiRW1CXX-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
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://github.com/intel-lab-lkp/linux/commit/3e00c2b4797c228b1939a15506c9ab807d0fa809
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jiapeng-Chong/fs-buffer-Remove-redundant-assignment-to-err/20230322-150022
        git checkout 3e00c2b4797c228b1939a15506c9ab807d0fa809
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303221812.QiRW1CXX-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from fs/buffer.c:24:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   In file included from include/linux/trace_events.h:9:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from fs/buffer.c:24:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   In file included from include/linux/trace_events.h:9:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from fs/buffer.c:24:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   In file included from include/linux/trace_events.h:9:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> fs/buffer.c:2639:1: warning: unused label 'out' [-Wunused-label]
   out:
   ^~~~
   fs/buffer.c:2282:5: warning: stack frame size (2144) exceeds limit (1024) in 'block_read_full_folio' [-Wframe-larger-than]
   int block_read_full_folio(struct folio *folio, get_block_t *get_block)
       ^
   79/2144 (3.68%) spills, 2065/2144 (96.32%) variables
   8 warnings generated.


vim +/out +2639 fs/buffer.c

^1da177e4c3f41 Linus Torvalds     2005-04-16  2572  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2573  int block_truncate_page(struct address_space *mapping,
^1da177e4c3f41 Linus Torvalds     2005-04-16  2574  			loff_t from, get_block_t *get_block)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2575  {
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2576  	pgoff_t index = from >> PAGE_SHIFT;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2577  	unsigned offset = from & (PAGE_SIZE-1);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2578  	unsigned blocksize;
54b21a7992a31d Andrew Morton      2006-01-08  2579  	sector_t iblock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2580  	unsigned length, pos;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2581  	struct inode *inode = mapping->host;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2582  	struct page *page;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2583  	struct buffer_head *bh;
3e00c2b4797c22 Jiapeng Chong      2023-03-22  2584  	int err = 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2585  
93407472a21b82 Fabian Frederick   2017-02-27  2586  	blocksize = i_blocksize(inode);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2587  	length = offset & (blocksize - 1);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2588  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2589  	/* Block boundary? Nothing to do */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2590  	if (!length)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2591  		return 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2592  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2593  	length = blocksize - length;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2594  	iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2595  	
^1da177e4c3f41 Linus Torvalds     2005-04-16  2596  	page = grab_cache_page(mapping, index);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2597  	if (!page)
3e00c2b4797c22 Jiapeng Chong      2023-03-22  2598  		return -ENOMEM;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2599  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2600  	if (!page_has_buffers(page))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2601  		create_empty_buffers(page, blocksize, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2602  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2603  	/* Find the buffer that contains "offset" */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2604  	bh = page_buffers(page);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2605  	pos = blocksize;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2606  	while (offset >= pos) {
^1da177e4c3f41 Linus Torvalds     2005-04-16  2607  		bh = bh->b_this_page;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2608  		iblock++;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2609  		pos += blocksize;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2610  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2611  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2612  	if (!buffer_mapped(bh)) {
b0cf2321c65991 Badari Pulavarty   2006-03-26  2613  		WARN_ON(bh->b_size != blocksize);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2614  		err = get_block(inode, iblock, bh, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2615  		if (err)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2616  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2617  		/* unmapped? It's a hole - nothing to do */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2618  		if (!buffer_mapped(bh))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2619  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2620  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2621  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2622  	/* Ok, it's mapped. Make sure it's up-to-date */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2623  	if (PageUptodate(page))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2624  		set_buffer_uptodate(bh);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2625  
33a266dda9fbbe David Chinner      2007-02-12  2626  	if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) {
e7ea1129afab0e Zhang Yi           2022-09-01  2627  		err = bh_read(bh, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2628  		/* Uhhuh. Read error. Complain and punt. */
e7ea1129afab0e Zhang Yi           2022-09-01  2629  		if (err < 0)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2630  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2631  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2632  
eebd2aa355692a Christoph Lameter  2008-02-04  2633  	zero_user(page, offset, length);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2634  	mark_buffer_dirty(bh);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2635  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2636  unlock:
^1da177e4c3f41 Linus Torvalds     2005-04-16  2637  	unlock_page(page);
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2638  	put_page(page);
^1da177e4c3f41 Linus Torvalds     2005-04-16 @2639  out:
^1da177e4c3f41 Linus Torvalds     2005-04-16  2640  	return err;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2641  }
1fe72eaa0f46a0 H Hartley Sweeten  2009-09-22  2642  EXPORT_SYMBOL(block_truncate_page);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2643  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH] fs/buffer: Remove redundant assignment to err
@ 2023-03-22 17:48 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-03-22 17:48 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check warning: fs/buffer.c:2639:1: sparse: sparse: unused label 'out'"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20230322065949.29223-1-jiapeng.chong@linux.alibaba.com>
References: <20230322065949.29223-1-jiapeng.chong@linux.alibaba.com>
TO: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
TO: viro@zeniv.linux.org.uk
CC: brauner@kernel.org
CC: linux-fsdevel@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
CC: Abaci Robot <abaci@linux.alibaba.com>

Hi Jiapeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on vfs-idmapping/for-next]
[also build test WARNING on linus/master v6.3-rc3 next-20230322]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jiapeng-Chong/fs-buffer-Remove-redundant-assignment-to-err/20230322-150022
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git for-next
patch link:    https://lore.kernel.org/r/20230322065949.29223-1-jiapeng.chong%40linux.alibaba.com
patch subject: [PATCH] fs/buffer: Remove redundant assignment to err
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: csky-randconfig-s051-20230322 (https://download.01.org/0day-ci/archive/20230323/202303230149.cdrll0qe-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/3e00c2b4797c228b1939a15506c9ab807d0fa809
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jiapeng-Chong/fs-buffer-Remove-redundant-assignment-to-err/20230322-150022
        git checkout 3e00c2b4797c228b1939a15506c9ab807d0fa809
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/r/202303230149.cdrll0qe-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> fs/buffer.c:2639:1: sparse: sparse: unused label 'out'

vim +/out +2639 fs/buffer.c

^1da177e4c3f41 Linus Torvalds     2005-04-16  2572  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2573  int block_truncate_page(struct address_space *mapping,
^1da177e4c3f41 Linus Torvalds     2005-04-16  2574  			loff_t from, get_block_t *get_block)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2575  {
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2576  	pgoff_t index = from >> PAGE_SHIFT;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2577  	unsigned offset = from & (PAGE_SIZE-1);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2578  	unsigned blocksize;
54b21a7992a31d Andrew Morton      2006-01-08  2579  	sector_t iblock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2580  	unsigned length, pos;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2581  	struct inode *inode = mapping->host;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2582  	struct page *page;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2583  	struct buffer_head *bh;
3e00c2b4797c22 Jiapeng Chong      2023-03-22  2584  	int err = 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2585  
93407472a21b82 Fabian Frederick   2017-02-27  2586  	blocksize = i_blocksize(inode);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2587  	length = offset & (blocksize - 1);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2588  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2589  	/* Block boundary? Nothing to do */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2590  	if (!length)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2591  		return 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2592  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2593  	length = blocksize - length;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2594  	iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2595  	
^1da177e4c3f41 Linus Torvalds     2005-04-16  2596  	page = grab_cache_page(mapping, index);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2597  	if (!page)
3e00c2b4797c22 Jiapeng Chong      2023-03-22  2598  		return -ENOMEM;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2599  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2600  	if (!page_has_buffers(page))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2601  		create_empty_buffers(page, blocksize, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2602  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2603  	/* Find the buffer that contains "offset" */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2604  	bh = page_buffers(page);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2605  	pos = blocksize;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2606  	while (offset >= pos) {
^1da177e4c3f41 Linus Torvalds     2005-04-16  2607  		bh = bh->b_this_page;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2608  		iblock++;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2609  		pos += blocksize;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2610  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2611  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2612  	if (!buffer_mapped(bh)) {
b0cf2321c65991 Badari Pulavarty   2006-03-26  2613  		WARN_ON(bh->b_size != blocksize);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2614  		err = get_block(inode, iblock, bh, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2615  		if (err)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2616  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2617  		/* unmapped? It's a hole - nothing to do */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2618  		if (!buffer_mapped(bh))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2619  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2620  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2621  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2622  	/* Ok, it's mapped. Make sure it's up-to-date */
^1da177e4c3f41 Linus Torvalds     2005-04-16  2623  	if (PageUptodate(page))
^1da177e4c3f41 Linus Torvalds     2005-04-16  2624  		set_buffer_uptodate(bh);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2625  
33a266dda9fbbe David Chinner      2007-02-12  2626  	if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) {
e7ea1129afab0e Zhang Yi           2022-09-01  2627  		err = bh_read(bh, 0);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2628  		/* Uhhuh. Read error. Complain and punt. */
e7ea1129afab0e Zhang Yi           2022-09-01  2629  		if (err < 0)
^1da177e4c3f41 Linus Torvalds     2005-04-16  2630  			goto unlock;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2631  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  2632  
eebd2aa355692a Christoph Lameter  2008-02-04  2633  	zero_user(page, offset, length);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2634  	mark_buffer_dirty(bh);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2635  
^1da177e4c3f41 Linus Torvalds     2005-04-16  2636  unlock:
^1da177e4c3f41 Linus Torvalds     2005-04-16  2637  	unlock_page(page);
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2638  	put_page(page);
^1da177e4c3f41 Linus Torvalds     2005-04-16 @2639  out:
^1da177e4c3f41 Linus Torvalds     2005-04-16  2640  	return err;
^1da177e4c3f41 Linus Torvalds     2005-04-16  2641  }
1fe72eaa0f46a0 H Hartley Sweeten  2009-09-22  2642  EXPORT_SYMBOL(block_truncate_page);
^1da177e4c3f41 Linus Torvalds     2005-04-16  2643  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

end of thread, other threads:[~2023-03-22 17:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22  6:59 [PATCH] fs/buffer: Remove redundant assignment to err Jiapeng Chong
2023-03-22  8:20 ` Christian Brauner
2023-03-22 11:07 ` kernel test robot
2023-03-22 17:48 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.