Lines Matching +full:buffered +full:- +full:negative
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Network filesystem high-level buffered write support.
62 if (ctx->ops->update_i_size) { in netfs_update_i_size()
63 ctx->ops->update_i_size(inode, pos); in netfs_update_i_size()
69 fscache_update_cookie(ctx->cache, NULL, &pos); in netfs_update_i_size()
72 gap = SECTOR_SIZE - (i_size & (SECTOR_SIZE - 1)); in netfs_update_i_size()
74 add = DIV_ROUND_UP(copied - gap, SECTOR_SIZE); in netfs_update_i_size()
76 inode->i_blocks = min_t(blkcnt_t, in netfs_update_i_size()
78 inode->i_blocks + add); in netfs_update_i_size()
83 * netfs_perform_write - Copy data into the pagecache.
93 * netfs-specific grouping such that data from an old group gets flushed before
99 struct file *file = iocb->ki_filp; in netfs_perform_write()
101 struct address_space *mapping = inode->i_mapping; in netfs_perform_write()
107 .range_start = iocb->ki_pos, in netfs_perform_write()
108 .range_end = iocb->ki_pos + iter->count, in netfs_perform_write()
112 unsigned int bdp_flags = (iocb->ki_flags & IOCB_NOWAIT) ? BDP_ASYNC : 0; in netfs_perform_write()
114 loff_t i_size, pos = iocb->ki_pos; in netfs_perform_write()
118 if (unlikely(test_bit(NETFS_ICTX_WRITETHROUGH, &ctx->flags) || in netfs_perform_write()
119 iocb->ki_flags & (IOCB_DSYNC | IOCB_SYNC)) in netfs_perform_write()
121 wbc_attach_fdatawrite_inode(&wbc, mapping->host); in netfs_perform_write()
123 ret = filemap_write_and_wait_range(mapping, pos, pos + iter->count); in netfs_perform_write()
129 wreq = netfs_begin_writethrough(iocb, iter->count); in netfs_perform_write()
137 wreq->iocb = iocb; in netfs_perform_write()
152 offset = pos & (max_chunk - 1); in netfs_perform_write()
153 part = min(max_chunk - offset, iov_iter_count(iter)); in netfs_perform_write()
166 ret = -EFAULT; in netfs_perform_write()
178 offset = pos - fpos; in netfs_perform_write()
179 part = min_t(size_t, flen - offset, part); in netfs_perform_write()
182 * the info in folio->private and may change it until it in netfs_perform_write()
187 ret = written ? -EINTR : -ERESTARTSYS; in netfs_perform_write()
192 ret = written ? -EINTR : -ERESTARTSYS; in netfs_perform_write()
197 * to do write-streaming, in which case we don't want to a in netfs_perform_write()
221 /* If the page is above the zero-point then we assume that the in netfs_perform_write()
225 if (fpos >= ctx->zero_point) { in netfs_perform_write()
226 zero_user_segment(&folio->page, 0, offset); in netfs_perform_write()
230 zero_user_segment(&folio->page, offset + copied, flen); in netfs_perform_write()
258 * a file that's open for reading as ->read_folio() then has to in netfs_perform_write()
261 if ((file->f_mode & FMODE_READ) || in netfs_perform_write()
272 /* Note that copy-to-cache may have been set. */ in netfs_perform_write()
283 ret = -EIO; in netfs_perform_write()
299 ret = -ENOMEM; in netfs_perform_write()
302 finfo->netfs_group = netfs_get_group(netfs_group); in netfs_perform_write()
303 finfo->dirty_offset = offset; in netfs_perform_write()
304 finfo->dirty_len = copied; in netfs_perform_write()
315 if (offset == finfo->dirty_offset + finfo->dirty_len) { in netfs_perform_write()
319 finfo->dirty_len += copied; in netfs_perform_write()
320 if (finfo->dirty_offset == 0 && finfo->dirty_len == flen) { in netfs_perform_write()
321 if (finfo->netfs_group) in netfs_perform_write()
322 folio_change_private(folio, finfo->netfs_group); in netfs_perform_write()
339 ret = filemap_write_and_wait_range(mapping, fpos, fpos + flen - 1); in netfs_perform_write()
379 set_bit(NETFS_ICTX_MODIFIED_ATTR, &ctx->flags); in netfs_perform_write()
380 if (unlikely(ctx->ops->post_modify)) in netfs_perform_write()
381 ctx->ops->post_modify(inode); in netfs_perform_write()
387 if (ret2 == -EIOCBQUEUED) in netfs_perform_write()
393 iocb->ki_pos += written; in netfs_perform_write()
398 ret = -EFAULT; in netfs_perform_write()
407 * netfs_buffered_write_iter_locked - write data to a file
415 * do direct IO or a standard buffered write.
427 * * negative error code if no data has been written at all
432 struct file *file = iocb->ki_filp; in netfs_buffered_write_iter_locked()
450 * netfs_file_write_iter - write data to a file
458 * * Negative error code if no data has been written at all of
464 struct file *file = iocb->ki_filp; in netfs_file_write_iter()
465 struct inode *inode = file->f_mapping->host; in netfs_file_write_iter()
469 _enter("%llx,%zx,%llx", iocb->ki_pos, iov_iter_count(from), i_size_read(inode)); in netfs_file_write_iter()
474 if ((iocb->ki_flags & IOCB_DIRECT) || in netfs_file_write_iter()
475 test_bit(NETFS_ICTX_UNBUFFERED, &ictx->flags)) in netfs_file_write_iter()
493 * Notification that a previously read-only page is about to become writable.
499 struct folio *folio = page_folio(vmf->page); in netfs_page_mkwrite()
500 struct file *file = vmf->vma->vm_file; in netfs_page_mkwrite()
501 struct address_space *mapping = file->f_mapping; in netfs_page_mkwrite()
507 _enter("%lx", folio->index); in netfs_page_mkwrite()
509 sb_start_pagefault(inode->i_sb); in netfs_page_mkwrite()
513 if (folio->mapping != mapping) { in netfs_page_mkwrite()
540 case -ENOMEM: in netfs_page_mkwrite()
555 set_bit(NETFS_ICTX_MODIFIED_ATTR, &ictx->flags); in netfs_page_mkwrite()
556 if (ictx->ops->post_modify) in netfs_page_mkwrite()
557 ictx->ops->post_modify(inode); in netfs_page_mkwrite()
560 sb_end_pagefault(inode->i_sb); in netfs_page_mkwrite()