Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4185451ioo; Wed, 25 May 2022 17:43:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9tV8us85VJ+H9aIpwPy05f6yIUx5LgjddadQUDrBrAJQdlnXg3oR4sqD7j81bB/MWtSd/ X-Received: by 2002:a17:902:a981:b0:156:52b2:40d6 with SMTP id bh1-20020a170902a98100b0015652b240d6mr35383876plb.34.1653525821168; Wed, 25 May 2022 17:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653525821; cv=none; d=google.com; s=arc-20160816; b=TsZr3d34r55lsUlwY0rGDUod7b1cFkCsVotX1FBZjfMo9aU8GtLB1j//8vWivMG7uf 7/vH1xn3RRkEVs1e0A1P9Y5bpWN3HwOqZ8lSVLHk2FM91Oj69VFw3WfOVB9qYi3PnvuK uuUWp83cOi126Gyp4kyHU4chzH0n8VHziTJt/RfN67LdLquk/xkDwara3aztZKyoSuTF hh4CtPR8q22lRvKvB8wpcrp3EAAzk8hZBLJmMiRiLViaWGcSP1whCoT0j8tg1t9njKtV AV1CPYcdHDagvhVXTT8u16efietT9GL8NqpOzI8lU8fNQNtVP4gGCb/dsVCVGWeRxXK4 r5Xg== 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=KkHoZ2rI1ZmWrFNbT4d5/e9glIVN8+RwmXeLMke2PRE=; b=qCT9Gtm6+5sPNpQ8/NAJkv4zNBf/SWSfXbB657LwJLkmFHPzdKKpKo2SMJVlrO0tfO 3pjAGD+T1Bok1xUfOGbUq25y+ttaK1NW+nylnop8LPTU2EXw7pc91TxZ2dIHtNkwFehV lMdEuH5cZ8CA2g4Xs/mqJzqwmIRRa3DD6py03oB2kEZwO37SdmFSY1YH2MJT9YEIBwfh mf5+CdToC6CuNL/EqSqK4aGOrpe+GVBJxXiJc/YWvf2TSPYymgyQvHqio5df4swb387o DpUoMC6NTJdg9WqaPuQfMtIH/YwanqPKmBqC6qzYAwhyw627ExZSwDdetDNqLiuYaZ2w FGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bLvAaUBM; 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 r188-20020a632bc5000000b003db7de73bd2si522260pgr.749.2022.05.25.17.43.05; Wed, 25 May 2022 17:43:41 -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=bLvAaUBM; 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 S244873AbiEYO1E (ORCPT + 99 others); Wed, 25 May 2022 10:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244670AbiEYO0h (ORCPT ); Wed, 25 May 2022 10:26:37 -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 ESMTP id 5E6B0F5AD for ; Wed, 25 May 2022 07:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653488795; 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=KkHoZ2rI1ZmWrFNbT4d5/e9glIVN8+RwmXeLMke2PRE=; b=bLvAaUBMzLfw3iehTSXDLxtY1y9xsoCWj17iiy95BkhtvHlauld3C/OUptng2p72Vk6Yvj 7W5H8l9/8hJ8SpZCsoTRQ/yheqfbdgTNp4MBt+V5SP7sIAMhYOmZPTqC8E7R803awgv1dm glYNvJzLmIP7dB7oA820v528gnGHTvs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-4Wr6m9orNUugVB7_FefKSg-1; Wed, 25 May 2022 10:26:32 -0400 X-MC-Unique: 4Wr6m9orNUugVB7_FefKSg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71FD4101A54E; Wed, 25 May 2022 14:26:31 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13332400F38; Wed, 25 May 2022 14:26:29 +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 Cc: Steve French , Shyam Prasad N , Rohith Surabattula , linux-cifs@vger.kernel.org, dhowells@redhat.com, Shyam Prasad N , Rohith Surabattula , Jeff Layton , Al Viro , linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 25 May 2022 15:26:29 +0100 Message-ID: <165348878940.2106726.204291614267188735.stgit@warthog.procyon.org.uk> In-Reply-To: <165348876794.2106726.9240233279581920208.stgit@warthog.procyon.org.uk> References: <165348876794.2106726.9240233279581920208.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.4 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.10 X-Spam-Status: No, score=-3.5 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/cifssmb.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index c0542bdcd06b..34ad965cde21 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/cifssmb.c b/fs/cifs/cifssmb.c index 47e927c4ff8d..2eedffef6f53 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -27,6 +27,7 @@ #include "cifsglob.h" #include "cifsacl.h" #include "cifsproto.h" +#include "cifsfs.h" #include "cifs_unicode.h" #include "cifs_debug.h" #include "smb2proto.h" @@ -1928,6 +1929,99 @@ cifs_writedata_release(struct kref *refcount) kfree(wdata); } +/* + * 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(); +} + /* * Write failed with a retryable error. Resend the write request. It's also * possible that the page was redirtied so re-clean the page.