Unverified Commit 1d5911d4 authored by Christian Brauner's avatar Christian Brauner
Browse files

Merge tag 'netfs-lib-20240109' of...

Merge tag 'netfs-lib-20240109' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into vfs.netfs

Pull netfs updates from David Howells:

A few follow-up fixes for the netfs work for this cycle.

* tag 'netfs-lib-20240109' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

:
  netfs: Fix wrong #ifdef hiding wait
  cachefiles: Fix signed/unsigned mixup
  netfs: Fix the loop that unmarks folios after writing to the cache
  netfs: Fix interaction between write-streaming and cachefiles culling
  netfs: Count DIO writes
  netfs: Mark netfs_unbuffered_write_iter_locked() static

Tested-by: default avatarMarc Dionne <marc.dionne@auristor.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parents d271c4b4 e2bdb527
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -522,18 +522,18 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
			       bool no_space_allocated_yet)
{
	struct cachefiles_cache *cache = object->volume->cache;
	unsigned long long start = *_start, pos;
	loff_t start = *_start, pos;
	size_t len = *_len;
	int ret;

	/* Round to DIO size */
	start = round_down(*_start, PAGE_SIZE);
	if (start != *_start) {
		kleave(" = -ENOBUFS [down]");
		return -ENOBUFS;
	}
	if (*_len > upper_len) {
		kleave(" = -ENOBUFS [up]");
	if (start != *_start || *_len > upper_len) {
		/* Probably asked to cache a streaming write written into the
		 * pagecache when the cookie was temporarily out of service to
		 * culling.
		 */
		fscache_count_dio_misfit();
		return -ENOBUFS;
	}

@@ -556,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
					  cachefiles_trace_seek_error);
		return pos;
	}
	if (pos >= start + *_len)
	if ((u64)pos >= (u64)start + *_len)
		goto check_space; /* Unallocated region */

	/* We have a block that's at least partially filled - if we're low on
@@ -575,7 +575,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
					  cachefiles_trace_seek_error);
		return pos;
	}
	if (pos >= start + *_len)
	if ((u64)pos >= (u64)start + *_len)
		return 0; /* Fully allocated */

	/* Partially allocated, but insufficient space: cull. */
+22 −5
Original line number Diff line number Diff line
@@ -80,10 +80,19 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx,
		return NETFS_WHOLE_FOLIO_MODIFY;

	if (file->f_mode & FMODE_READ)
		return NETFS_JUST_PREFETCH;

	if (netfs_is_cache_enabled(ctx))
		return NETFS_JUST_PREFETCH;
		goto no_write_streaming;
	if (test_bit(NETFS_ICTX_NO_WRITE_STREAMING, &ctx->flags))
		goto no_write_streaming;

	if (netfs_is_cache_enabled(ctx)) {
		/* We don't want to get a streaming write on a file that loses
		 * caching service temporarily because the backing store got
		 * culled.
		 */
		if (!test_bit(NETFS_ICTX_NO_WRITE_STREAMING, &ctx->flags))
			set_bit(NETFS_ICTX_NO_WRITE_STREAMING, &ctx->flags);
		goto no_write_streaming;
	}

	if (!finfo)
		return NETFS_STREAMING_WRITE;
@@ -95,6 +104,13 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx,
	if (offset == finfo->dirty_offset + finfo->dirty_len)
		return NETFS_STREAMING_WRITE_CONT;
	return NETFS_FLUSH_CONTENT;

no_write_streaming:
	if (finfo) {
		netfs_stat(&netfs_n_wh_wstream_conflict);
		return NETFS_FLUSH_CONTENT;
	}
	return NETFS_JUST_PREFETCH;
}

/*
@@ -682,6 +698,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
	end_wb:
		if (folio_test_fscache(folio))
			folio_end_fscache(folio);
		xas_advance(&xas, folio_next_index(folio) - 1);
		folio_end_writeback(folio);
	}

@@ -1059,7 +1076,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
		folio_unlock(folio);
		if (wbc->sync_mode != WB_SYNC_NONE) {
			folio_wait_writeback(folio);
#ifdef CONFIG_NETFS_FSCACHE
#ifdef CONFIG_FSCACHE
			folio_wait_fscache(folio);
#endif
			goto lock_again;
+3 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ static void netfs_cleanup_dio_write(struct netfs_io_request *wreq)
 * Perform an unbuffered write where we may have to do an RMW operation on an
 * encrypted file.  This can also be used for direct I/O writes.
 */
ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter,
static ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter,
						  struct netfs_group *netfs_group)
{
	struct netfs_io_request *wreq;
@@ -140,6 +140,7 @@ ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from)
	_enter("%llx,%zx,%llx", iocb->ki_pos, iov_iter_count(from), i_size_read(inode));

	trace_netfs_write_iter(iocb, from);
	netfs_stat(&netfs_n_rh_dio_write);

	ret = netfs_start_io_direct(inode);
	if (ret < 0)
+6 −3
Original line number Diff line number Diff line
@@ -48,13 +48,15 @@ atomic_t fscache_n_no_create_space;
EXPORT_SYMBOL(fscache_n_no_create_space);
atomic_t fscache_n_culled;
EXPORT_SYMBOL(fscache_n_culled);
atomic_t fscache_n_dio_misfit;
EXPORT_SYMBOL(fscache_n_dio_misfit);

/*
 * display the general statistics
 */
int fscache_stats_show(struct seq_file *m)
{
	seq_puts(m, "FS-Cache statistics\n");
	seq_puts(m, "-- FS-Cache statistics --\n");
	seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
		   atomic_read(&fscache_n_cookies),
		   atomic_read(&fscache_n_volumes),
@@ -93,8 +95,9 @@ int fscache_stats_show(struct seq_file *m)
		   atomic_read(&fscache_n_no_create_space),
		   atomic_read(&fscache_n_culled));

	seq_printf(m, "IO     : rd=%u wr=%u\n",
	seq_printf(m, "IO     : rd=%u wr=%u mis=%u\n",
		   atomic_read(&fscache_n_read),
		   atomic_read(&fscache_n_write));
		   atomic_read(&fscache_n_write),
		   atomic_read(&fscache_n_dio_misfit));
	return 0;
}
+2 −6
Original line number Diff line number Diff line
@@ -26,12 +26,6 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq);
int netfs_prefetch_for_write(struct file *file, struct folio *folio,
			     size_t offset, size_t len);

/*
 * direct_write.c
 */
ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter,
					   struct netfs_group *netfs_group);

/*
 * io.c
 */
@@ -110,6 +104,7 @@ int netfs_end_writethrough(struct netfs_io_request *wreq, struct kiocb *iocb);
 */
#ifdef CONFIG_NETFS_STATS
extern atomic_t netfs_n_rh_dio_read;
extern atomic_t netfs_n_rh_dio_write;
extern atomic_t netfs_n_rh_readahead;
extern atomic_t netfs_n_rh_readpage;
extern atomic_t netfs_n_rh_rreq;
@@ -128,6 +123,7 @@ extern atomic_t netfs_n_rh_write_begin;
extern atomic_t netfs_n_rh_write_done;
extern atomic_t netfs_n_rh_write_failed;
extern atomic_t netfs_n_rh_write_zskip;
extern atomic_t netfs_n_wh_wstream_conflict;
extern atomic_t netfs_n_wh_upload;
extern atomic_t netfs_n_wh_upload_done;
extern atomic_t netfs_n_wh_upload_failed;
Loading