Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3796167rwa; Tue, 23 Aug 2022 10:13:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CJHRIZQ/dtWgQaVTQDllCiyzgy3qI+vFYUEA+RncRkL2+LtmXqg2w3Jp3RDkS6KH4vnV1 X-Received: by 2002:a63:8243:0:b0:422:b70e:7542 with SMTP id w64-20020a638243000000b00422b70e7542mr21501006pgd.10.1661274814107; Tue, 23 Aug 2022 10:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661274814; cv=none; d=google.com; s=arc-20160816; b=ZPqoIma4KQuXpSGNI91IEQwsgNHjqCp2JyKl7FtrL3pBGGbInC0a5cxIiyEYXwK+zf RwzGh+49MpVmGT1t9I+3vccyHgqqWNsYADaCB7xAUIRKczfpmu8UEGcequIeQ6fTCNxP oFR75Iitrt1uvNs9n366F/34KYdI/w6U8OKljzY1QR4g6o7jgZCrkfS+EXB/odIoy0HE TXzJDGZHSg4VsaGfAoCkYVfdGm0ST2PHzEa6ipGOYqpUA4De8coaQNyNtETyA4k27htq gYfKGEQ9qtbKpYxRs5qhAHUMHC89wzbdVGFXJj2kvTLpwqBJM3kkvCUFfGwEdImcuzMe MBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=P183HfthAts50D8fWVytaERlozP35z9ACI09QEFtgmY=; b=b7de3Wh+xYAVLwUQUU21fbgpihmdoXi9Gd3B65c6IrCIgSsdYjmehN5TQyRpaisfj+ oILkPCTopDC9swPgZ042+ndwoxduFBzy1QR+gNyx1ksJyd1fETJ/x2YFSE9Zg6Nhdirw zz9AEBx4CHWl9Q/KNM/2OoPIF1X6HRPVzrJYeAkR/zmMzmkfvy/NkNvmigEjEkMzSFRs EHTNZbiSKTIeXrqxtXAFcwQcSvldePdYfh7oZf9RQfQZ+/O1yWCfsiYxDSsGl21LMUAR HL3nCOwQ9+fltf5lCvUn3+acFAaUyEtuTOkssxVa0KeZ6jJOakUoveTv2E/ZEMfXoTsT Ht1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e5xUG+cG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a170902db0c00b0016d9e2b9a0fsi17314780plx.340.2022.08.23.10.13.23; Tue, 23 Aug 2022 10:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e5xUG+cG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344181AbiHWRBC (ORCPT + 99 others); Tue, 23 Aug 2022 13:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343741AbiHWRAP (ORCPT ); Tue, 23 Aug 2022 13:00:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BDDBD165 for ; Tue, 23 Aug 2022 07:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661263953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P183HfthAts50D8fWVytaERlozP35z9ACI09QEFtgmY=; b=e5xUG+cGRJBy0tlazxD7jO0EwSoaXtKLrxIGJ/nWAsoSXoXYt8L9u1xDYVIWO875XOJ9OU dtzYSPo+08swGBTKE2iY10HaCbNswsQhdCKQYFd2UmzaRTA0oRdZ+XPdYJmIuOCg9lOIKk NqyxbxxZOcDnJpKc1i5zdKDFZA0X2Bg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-2FsjouFkOsWoKSyaGlTn3A-1; Tue, 23 Aug 2022 10:12:32 -0400 X-MC-Unique: 2FsjouFkOsWoKSyaGlTn3A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5ACD3C0E218; Tue, 23 Aug 2022 14:12:29 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B3B3C15BB3; Tue, 23 Aug 2022 14:12:28 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 3/7] cifs: Add some helper functions From: David Howells To: Steve French , Al Viro Cc: Steve French , Shyam Prasad N , Rohith Surabattula , linux-cifs@vger.kernel.org, dhowells@redhat.com, Shyam Prasad N , Rohith Surabattula , Jeff Layton , linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 23 Aug 2022 15:12:28 +0100 Message-ID: <166126394799.708021.10637797063862600488.stgit@warthog.procyon.org.uk> In-Reply-To: <166126392703.708021.14465850073772688008.stgit@warthog.procyon.org.uk> References: <166126392703.708021.14465850073772688008.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add some helper functions to manipulate the folio marks by iterating through a list of folios held in an xarray rather than using a page list. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: linux-cifs@vger.kernel.org --- fs/cifs/cifsfs.h | 3 ++ fs/cifs/file.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 81f4c15936d0..bbc7aa31cc94 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -110,6 +110,9 @@ extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *); extern const struct file_operations cifs_dir_ops; extern int cifs_dir_open(struct inode *inode, struct file *file); extern int cifs_readdir(struct file *file, struct dir_context *ctx); +extern void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len); +extern void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len); +extern void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int len); /* Functions related to dir entries */ extern const struct dentry_operations cifs_dentry_ops; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index fa738adc031f..6dfd96715274 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -36,6 +36,99 @@ #include "cifs_ioctl.h" #include "cached_dir.h" +/* + * Completion of write to server. + */ +void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len) +{ + struct address_space *mapping = inode->i_mapping; + struct folio *folio; + pgoff_t end; + + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); + + if (!len) + return; + + rcu_read_lock(); + + end = (start + len - 1) / PAGE_SIZE; + xas_for_each(&xas, folio, end) { + if (!folio_test_writeback(folio)) { + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", + len, start, folio_index(folio), end); + continue; + } + + folio_detach_private(folio); + folio_end_writeback(folio); + } + + rcu_read_unlock(); +} + +/* + * Failure of write to server. + */ +void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len) +{ + struct address_space *mapping = inode->i_mapping; + struct folio *folio; + pgoff_t end; + + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); + + if (!len) + return; + + rcu_read_lock(); + + end = (start + len - 1) / PAGE_SIZE; + xas_for_each(&xas, folio, end) { + if (!folio_test_writeback(folio)) { + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", + len, start, folio_index(folio), end); + continue; + } + + folio_set_error(folio); + folio_end_writeback(folio); + } + + rcu_read_unlock(); +} + +/* + * Redirty pages after a temporary failure. + */ +void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int len) +{ + struct address_space *mapping = inode->i_mapping; + struct folio *folio; + pgoff_t end; + + XA_STATE(xas, &mapping->i_pages, start / PAGE_SIZE); + + if (!len) + return; + + rcu_read_lock(); + + end = (start + len - 1) / PAGE_SIZE; + xas_for_each(&xas, folio, end) { + if (!folio_test_writeback(folio)) { + WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", + len, start, folio_index(folio), end); + continue; + } + + filemap_dirty_folio(folio->mapping, folio); + folio_end_writeback(folio); + } + + rcu_read_unlock(); +} + /* * Mark as invalid, all open files on tree connections since they * were closed when session to server was lost.