lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <19757b9e-1193-42cb-8d11-33c4e92336cf@linux.alibaba.com>
Date: Mon, 12 Jan 2026 13:37:12 +0800
From: Jingbo Xu <jefflexu@...ux.alibaba.com>
To: Markus Elfring <Markus.Elfring@....de>, linux-fsdevel@...r.kernel.org,
 Bernd Schubert <bschubert@....com>, Miklos Szeredi <miklos@...redi.hu>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] fuse: invalidate the page cache after direct write



On 1/11/26 4:18 PM, Markus Elfring wrote:
> …
>> +++ b/fs/fuse/file.c
>> @@ -667,6 +667,18 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
>>  			struct inode *inode = file_inode(io->iocb->ki_filp);
>>  			struct fuse_conn *fc = get_fuse_conn(inode);
>>  			struct fuse_inode *fi = get_fuse_inode(inode);
>> +			struct address_space *mapping = io->iocb->ki_filp->f_mapping;
>> +
>> +			/*
>> +			 * As in generic_file_direct_write(), invalidate after the
>> +			 * write, to invalidate read-ahead cache that may have competed
>> +			 * with the write.
>> +			 */
>> +			if (io->write && res && mapping->nrpages) {
>> +				invalidate_inode_pages2_range(mapping,
>> +						io->offset >> PAGE_SHIFT,
>> +						(io->offset + res - 1) >> PAGE_SHIFT);
>> +			}
>>  
>>  			spin_lock(&fi->lock);
> …
>> @@ -1160,10 +1174,26 @@ static ssize_t fuse_send_write(struct fuse_io_args *ia, loff_t pos,
> …
> -	return err ?: ia->write.out.size;
>> +	/*
>> +	 * Without FOPEN_DIRECT_IO, generic_file_direct_write() does the
>> +	 * invalidation for us.
>> +	 */
>> +	if (!err && written && mapping->nrpages &&
>> +	    (ff->open_flags & FOPEN_DIRECT_IO)) {
>> +		/*
>> +		 * As in generic_file_direct_write(), invalidate after the
>> +		 * write, to invalidate read-ahead cache that may have competed
>> +		 * with the write.
>> +		 */
>> +		invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT,
>> +					(pos + written - 1) >> PAGE_SHIFT);
>> +	}
>> +
>> +	return err ?: written;
> …
> 
> You may omit curly brackets at selected source code places.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.19-rc4#n197
> 

It's generally true for **simple** single statement.  I would prefer
adding the braces as it's a multi-line statement with a comment block.


-- 
Thanks,
Jingbo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ