// SPDX-License-Identifier: GPL-2.0-or-later /* Single, monolithic object support (e.g. AFS directory). * * Copyright (C) 2024 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
/** * netfs_single_mark_inode_dirty - Mark a single, monolithic object inode dirty * @inode: The inode to mark * * Mark an inode that contains a single, monolithic object as dirty so that its * writepages op will get called. If set, the SINGLE_NO_UPLOAD flag indicates * that the object will only be written to the cache and not uploaded (e.g. AFS * directory contents).
*/ void netfs_single_mark_inode_dirty(struct inode *inode)
{ struct netfs_inode *ictx = netfs_inode(inode); bool cache_only = test_bit(NETFS_ICTX_SINGLE_NO_UPLOAD, &ictx->flags); bool caching = fscache_cookie_enabled(netfs_i_cookie(netfs_inode(inode)));
/* * Perform a read to a buffer from the cache or the server. Only a single * subreq is permitted as the object must be fetched in a single transaction.
*/ staticint netfs_single_dispatch_read(struct netfs_io_request *rreq)
{ struct netfs_io_stream *stream = &rreq->io_streams[0]; struct netfs_io_subrequest *subreq; int ret = 0;
subreq = netfs_alloc_subrequest(rreq); if (!subreq) return -ENOMEM;
spin_lock(&rreq->lock);
list_add_tail(&subreq->rreq_link, &stream->subrequests);
trace_netfs_sreq(subreq, netfs_sreq_trace_added);
stream->front = subreq; /* Store list pointers before active flag */
smp_store_release(&stream->active, true);
spin_unlock(&rreq->lock);
netfs_single_cache_prepare_read(rreq, subreq); switch (subreq->source) { case NETFS_DOWNLOAD_FROM_SERVER:
netfs_stat(&netfs_n_rh_download); if (rreq->netfs_ops->prepare_read) {
ret = rreq->netfs_ops->prepare_read(subreq); if (ret < 0) goto cancel;
}
rreq->netfs_ops->issue_read(subreq);
rreq->submitted += subreq->len; break; case NETFS_READ_FROM_CACHE:
trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
netfs_single_read_cache(rreq, subreq);
rreq->submitted += subreq->len;
ret = 0; break; default:
pr_warn("Unexpected single-read source %u\n", subreq->source);
WARN_ON_ONCE(true);
ret = -EIO; break;
}
/** * netfs_read_single - Synchronously read a single blob of pages. * @inode: The inode to read from. * @file: The file we're using to read or NULL. * @iter: The buffer we're reading into. * * Fulfil a read request for a single monolithic object by drawing data from * the cache if possible, or the netfs if not. The buffer may be larger than * the file content; unused beyond the EOF will be zero-filled. The content * will be read with a single I/O request (though this may be retried). * * The calling netfs must initialise a netfs context contiguous to the vfs * inode before calling this. * * This is usable whether or not caching is enabled. If caching is enabled, * the data will be stored as a single object into the cache.
*/
ssize_t netfs_read_single(struct inode *inode, struct file *file, struct iov_iter *iter)
{ struct netfs_io_request *rreq; struct netfs_inode *ictx = netfs_inode(inode);
ssize_t ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.