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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZDT0JFmwg/9ijdcv@infradead.org>
Date:   Mon, 10 Apr 2023 22:46:12 -0700
From:   Christoph Hellwig <hch@...radead.org>
To:     "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Cc:     linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
        Jan Kara <jack@...e.cz>, Christoph Hellwig <hch@...radead.org>,
        "Darrick J . Wong" <djwong@...nel.org>,
        Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Subject: Re: [RFCv2 5/8] ext2: Move direct-io to use iomap

On Tue, Apr 11, 2023 at 10:51:53AM +0530, Ritesh Harjani (IBM) wrote:
> +extern void ext2_write_failed(struct address_space *mapping, loff_t to);

No need for the extern.

> +	/* handle case for partial write and for fallback to buffered write */
> +	if (ret >= 0 && iov_iter_count(from)) {
> +		loff_t pos, endbyte;
> +		ssize_t status;
> +		int ret2;
> +
> +		iocb->ki_flags &= ~IOCB_DIRECT;
> +		pos = iocb->ki_pos;
> +		status = generic_perform_write(iocb, from);
> +		if (unlikely(status < 0)) {
> +			ret = status;
> +			goto out_unlock;
> +		}
> +
> +		iocb->ki_pos += status;
> +		ret += status;
> +		endbyte = pos + status - 1;
> +		ret2 = filemap_write_and_wait_range(inode->i_mapping, pos,
> +						    endbyte);
> +		if (!ret2)
> +			invalidate_mapping_pages(inode->i_mapping,
> +						 pos >> PAGE_SHIFT,
> +						 endbyte >> PAGE_SHIFT);
> +		if (ret > 0)
> +			generic_write_sync(iocb, ret);
> +	}

Nit, but to me it would seem cleaner if all the fallback handling
was moved into a separate helper function.  Or in fact by not
using generic_file_write_iter even for buffered I/O and at doing
the pre-I/O checks and the final generic_write_sync in common code in
ext2 for direct and buffered I/O.

> +	/*
> +	 * For writes that could fill holes inside i_size on a
> +	 * DIO_SKIP_HOLES filesystem we forbid block creations: only
> +	 * overwrites are permitted.
> +	 */
> +	if ((flags & IOMAP_DIRECT) && (first_block << blkbits < i_size_read(inode)))
> +		create = 0;

No need for braes around the < operation, but I think you might need
them around the shift.

Also an overly long line here.

> +	if ((flags & IOMAP_WRITE) && (offset + length > i_size_read(inode)))

No need for the second set of inner braces here either.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ