linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Jan Kara <jack@suse.cz>
Cc: Eric Biggers <ebiggers@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the f2fs tree with the ext3 tree
Date: Fri, 23 Jul 2021 10:21:28 +1000	[thread overview]
Message-ID: <20210723102128.5fc92369@canb.auug.org.au> (raw)

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

Hi all,

Today's linux-next merge of the f2fs tree got a conflict in:

  fs/f2fs/file.c

between commit:

  edc6d01bad73 ("f2fs: Convert to using invalidate_lock")

from the ext3 tree and commit:

  5f2632fa1471 ("f2fs: reduce indentation in f2fs_file_write_iter()")

from the f2fs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/f2fs/file.c
index 1ff333755721,279252c7f7bc..000000000000
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@@ -4252,79 -4318,54 +4316,54 @@@ static ssize_t f2fs_file_write_iter(str
  	}
  
  	ret = generic_write_checks(iocb, from);
- 	if (ret > 0) {
- 		bool preallocated = false;
- 		size_t target_size = 0;
- 		int err;
- 
- 		if (iov_iter_fault_in_readable(from, iov_iter_count(from)))
- 			set_inode_flag(inode, FI_NO_PREALLOC);
- 
- 		if ((iocb->ki_flags & IOCB_NOWAIT)) {
- 			if (!f2fs_overwrite_io(inode, iocb->ki_pos,
- 						iov_iter_count(from)) ||
- 				f2fs_has_inline_data(inode) ||
- 				f2fs_force_buffered_io(inode, iocb, from)) {
- 				clear_inode_flag(inode, FI_NO_PREALLOC);
- 				inode_unlock(inode);
- 				ret = -EAGAIN;
- 				goto out;
- 			}
- 			goto write;
- 		}
- 
- 		if (is_inode_flag_set(inode, FI_NO_PREALLOC))
- 			goto write;
+ 	if (ret <= 0)
+ 		goto out_unlock;
  
- 		if (iocb->ki_flags & IOCB_DIRECT) {
- 			/*
- 			 * Convert inline data for Direct I/O before entering
- 			 * f2fs_direct_IO().
- 			 */
- 			err = f2fs_convert_inline_inode(inode);
- 			if (err)
- 				goto out_err;
- 			/*
- 			 * If force_buffere_io() is true, we have to allocate
- 			 * blocks all the time, since f2fs_direct_IO will fall
- 			 * back to buffered IO.
- 			 */
- 			if (!f2fs_force_buffered_io(inode, iocb, from) &&
- 					allow_outplace_dio(inode, iocb, from))
- 				goto write;
+ 	if (iocb->ki_flags & IOCB_NOWAIT) {
+ 		if (!f2fs_overwrite_io(inode, iocb->ki_pos,
+ 				       iov_iter_count(from)) ||
+ 		    f2fs_has_inline_data(inode) ||
+ 		    f2fs_force_buffered_io(inode, iocb, from)) {
+ 			ret = -EAGAIN;
+ 			goto out_unlock;
  		}
- 		preallocated = true;
- 		target_size = iocb->ki_pos + iov_iter_count(from);
+ 	}
+ 	if (iocb->ki_flags & IOCB_DIRECT) {
+ 		/*
+ 		 * Convert inline data for Direct I/O before entering
+ 		 * f2fs_direct_IO().
+ 		 */
+ 		ret = f2fs_convert_inline_inode(inode);
+ 		if (ret)
+ 			goto out_unlock;
+ 	}
  
- 		err = f2fs_preallocate_blocks(iocb, from);
- 		if (err) {
- out_err:
- 			clear_inode_flag(inode, FI_NO_PREALLOC);
- 			inode_unlock(inode);
- 			ret = err;
- 			goto out;
- 		}
- write:
- 		ret = __generic_file_write_iter(iocb, from);
- 		clear_inode_flag(inode, FI_NO_PREALLOC);
+ 	/* Possibly preallocate the blocks for the write. */
+ 	target_size = iocb->ki_pos + iov_iter_count(from);
+ 	preallocated = f2fs_preallocate_blocks(iocb, from);
+ 	if (preallocated < 0) {
+ 		ret = preallocated;
+ 		goto out_unlock;
+ 	}
  
- 		/* if we couldn't write data, we should deallocate blocks. */
- 		if (preallocated && i_size_read(inode) < target_size) {
- 			down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
- 			filemap_invalidate_lock(inode->i_mapping);
- 			f2fs_truncate(inode);
- 			filemap_invalidate_unlock(inode->i_mapping);
- 			up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
- 		}
+ 	ret = __generic_file_write_iter(iocb, from);
  
- 		if (ret > 0)
- 			f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret);
+ 	/* Don't leave any preallocated blocks around past i_size. */
+ 	if (preallocated > 0 && inode->i_size < target_size) {
+ 		down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 -		down_write(&F2FS_I(inode)->i_mmap_sem);
++		filemap_invalidate_lock(inode->i_mapping);
+ 		f2fs_truncate(inode);
 -		up_write(&F2FS_I(inode)->i_mmap_sem);
++		filemap_invalidate_unlock(inode->i_mapping);
+ 		up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
  	}
- unlock:
+ 	clear_inode_flag(inode, FI_PREALLOCATED_ALL);
+ 
+ 	if (ret > 0)
+ 		f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret);
+ out_unlock:
  	inode_unlock(inode);
  out:
- 	trace_f2fs_file_write_iter(inode, iocb->ki_pos,
- 					iov_iter_count(from), ret);
+ 	trace_f2fs_file_write_iter(inode, orig_pos, orig_count, ret);
  	if (ret > 0)
  		ret = generic_write_sync(iocb, ret);
  	return ret;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2021-07-23  0:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23  0:21 Stephen Rothwell [this message]
2021-08-24 23:51 linux-next: manual merge of the f2fs tree with the ext3 tree Stephen Rothwell

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=20210723102128.5fc92369@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ebiggers@google.com \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).