From patchwork Fri Nov 17 21:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13459604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57E10C5ACB3 for ; Fri, 17 Nov 2023 21:19:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5CE08D0066; Fri, 17 Nov 2023 16:19:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0D138D005B; Fri, 17 Nov 2023 16:19:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CADD58D0066; Fri, 17 Nov 2023 16:19:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BC6AF8D005B for ; Fri, 17 Nov 2023 16:19:04 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 97E2F80E06 for ; Fri, 17 Nov 2023 21:19:04 +0000 (UTC) X-FDA: 81468711408.17.14A3E39 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id D13C812001D for ; Fri, 17 Nov 2023 21:19:02 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fstTcJD8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700255942; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wytdEGMiDkVc14tR/9rfg5yMQrHZM30J/9oi3ehTfaw=; b=qCYw99OFmW3+06il56kxKf8tNZy8scaAHfKj77O4zW9INI4LyIDUaaRIthzM80IDiu06wu 9ksX+ujiLxA9+RxnWZP3eNrzOKWJuUf63PdQaYn/jtiCuTrVnGoN1ljff+2C57FqfeJDQZ s9T7RP/rjMWBaIYI3VFSskV60ksqX60= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fstTcJD8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700255942; a=rsa-sha256; cv=none; b=ANsgcFyDhwK1UDX1wDwNWor5j5QHBTYywgPGpMh+h+eERBSNDafVvH3vwewJfP2Oyg16Sp nzKko3rJ92AqWzXGXuJ8siz0B+7bgR/CYW0ag8N2Ti74gk8rUHZS/eERiDZ+45QTfluyJG lQn3ZCJo6HhD44jlwSO+tzIDffhHZ9c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wytdEGMiDkVc14tR/9rfg5yMQrHZM30J/9oi3ehTfaw=; b=fstTcJD8TVHj0xUVjEZMU12z+p4yDlA5DHPUCeNqTgVsSTLOSjxgbgYhztjkG8oUJsGfxD AaDJcDbG2KE5mQgZXuO8RP/kDbRCjGkMF1gP2OCuG1favJiQ+sv+QJ6Lm5Du7ZdVhwT29V 5A0DVvO2Ly888TUkXayMBsG8vzG6csA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-0OIdyLFiNPymhSR_8S1xlg-1; Fri, 17 Nov 2023 16:18:52 -0500 X-MC-Unique: 0OIdyLFiNPymhSR_8S1xlg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F6E13C0C48C; Fri, 17 Nov 2023 21:18:51 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80EF91121306; Fri, 17 Nov 2023 21:18:48 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v2 47/51] cifs: Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c Date: Fri, 17 Nov 2023 21:15:39 +0000 Message-ID: <20231117211544.1740466-48-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D13C812001D X-Stat-Signature: rjimt8bij1qpaqe671jb9p6otctroxus X-Rspam-User: X-HE-Tag: 1700255942-446980 X-HE-Meta: U2FsdGVkX197ixRenSia24ZqE3OC20J4JXqZXrrdTckkCfgH5dlciYAzLD872QVEBXIx9Ed5QBN96b14dN9D/rdAi5oK1OqzH/fhlNHFRn2F2k/Kp2RxePo/om+dI0+jjVmKqwQ8ODGpdr3KBWbGwkwPMYHIHb5nX/S+W+WSnqhWtcSU8BmOhTfk9PMxXU5I+Zs5vnLwF8iMwI6/L5JYKhWYdPc9h64mZaYZYEfYC1LC1FF7RlWlqoiW8xfwO0Uo+ZciPhDG91weF1YUCOAME0GxNs++mtWlNW2Erf3wHTiTr397wqqV31EQuG7G8Q4WnxtPMjPcisDMig7DIJqQO9N3PVkoae7+1+gpK+Ow0kqYAx+tXNfixOnbcx5dg4C/gphG3qaR0fd1TuNL56TC3PgISNIJYLObUzDNlV7/ZBpf5AfdswaFUM9RV0bS4+EKNZgFSVoxu75kPn/rspIocJG64iVjPSX3IjWTX3nIO2hKPIV5zhtHo/l2KgGBsHVIh+cXLbzfyBWhOWtswTHSaBx7KqhPLZhuY2G5xMZjYEmLZ8v7FQBLOvF0iECfM/OEwyiRbp1ztMMZloVYhIp99gyEc9SstDCQEDd/7cUP1bWlUT+CmgOFESE0UsAV4QYLIe7TOpkWWpBUXymOVm68Wj1aTYe2A+LrCWBxtqZQvygaiW2/9qyGEeA5iuuue5sZ+OGQn/c0ffNqqo9Jc8FfpBbc4Y02WEgoz2nP8hRlLxUJ9oBDKcseBBGqNxvoNB5MC82MlNu6mmIAstPXYI1dV905iUO9gDilw1tKgqkIN/026v+78G2D1imXxfm2WXdWSmGBxAEvq7jMZL+6N34LWn1Ns2wmoCfbpfdRrnM8kWArBYdAj2CNjrh0qeIhe/oShKjUxUhfQ/FFZQkU552geNCoHaGfdrzP62i362ztN7eafInDvUHrFWkJuGRQZHASQQJ6ypImsCtLDvqPOCs a0NfB/lk 69p1xFZmFZYtQ3Hg2kp6ohyzZMWXVG409gQyrQC++b+poYkgFAXKxVCVKRZJiS6OYj+zraNKXw830ssSzFLsRAT6yAnJdRHdHQ7qZIkCu/RNhB2LxPbqg7ryND3ft0vNW3e1EXWsgYPXUSN6IBqx3+e7AExfu0aRnMeaF5GneNAQRr7JssFE8Lfr6g0HruDjN7E1numIfmY3Hr3/ID4UzUHrO/23vRa4OZWNaqRMlWbeeewAQs8XIwH+Sbl2YAozyHL4dadq/WOR2gYd+7CireX3cH0vl+HkenkJRiLQ3dRdL/ZlxDCVfrXwVZaQo848IA5JnQqQLcwQMBqrdd/oRO4yy+mjFLrA56Urq7PzKyx4MPNbIsrfJ6OgI4xXY7wFECqUQnhPmRyrhxquR+qIniZq5Zqm+ufhHH3mZY8GHjpNIrQWFI9pJGNeYQdBdFeVXbNY5qQRWJ0hN94jXDBei7CXOxs3W6P8h0b3B98C83L3TYUJRPK2R9RCHDw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c so that they are colocated with similar functions rather than being split with cifsfs.c. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/cifsfs.c | 55 ------------------------------------------ fs/smb/client/cifsfs.h | 2 ++ fs/smb/client/file.c | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index c7d8251c28d5..439473aff211 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -982,61 +982,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, return root; } - -static ssize_t -cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) -{ - ssize_t rc; - struct inode *inode = file_inode(iocb->ki_filp); - - if (iocb->ki_flags & IOCB_DIRECT) - return cifs_user_readv(iocb, iter); - - rc = cifs_revalidate_mapping(inode); - if (rc) - return rc; - - return generic_file_read_iter(iocb, iter); -} - -static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - struct inode *inode = file_inode(iocb->ki_filp); - struct cifsInodeInfo *cinode = CIFS_I(inode); - ssize_t written; - int rc; - - if (iocb->ki_filp->f_flags & O_DIRECT) { - written = cifs_user_writev(iocb, from); - if (written > 0 && CIFS_CACHE_READ(cinode)) { - cifs_zap_mapping(inode); - cifs_dbg(FYI, - "Set no oplock for inode=%p after a write operation\n", - inode); - cinode->oplock = 0; - } - return written; - } - - written = cifs_get_writer(cinode); - if (written) - return written; - - written = generic_file_write_iter(iocb, from); - - if (CIFS_CACHE_WRITE(CIFS_I(inode))) - goto out; - - rc = filemap_fdatawrite(inode->i_mapping); - if (rc) - cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n", - rc, inode); - -out: - cifs_put_writer(cinode); - return written; -} - static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) { struct cifsFileInfo *cfile = file->private_data; diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h index 3adea10aa9da..28c41c449205 100644 --- a/fs/smb/client/cifsfs.h +++ b/fs/smb/client/cifsfs.h @@ -100,6 +100,8 @@ extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from); +ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from); +ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter); extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock); extern int cifs_lock(struct file *, int, struct file_lock *); extern int cifs_fsync(struct file *, loff_t, loff_t, int); diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 36128a39e417..5ecbda31ba85 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4583,6 +4583,59 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) return __cifs_readv(iocb, to, false); } +ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + ssize_t rc; + struct inode *inode = file_inode(iocb->ki_filp); + + if (iocb->ki_flags & IOCB_DIRECT) + return cifs_user_readv(iocb, iter); + + rc = cifs_revalidate_mapping(inode); + if (rc) + return rc; + + return generic_file_read_iter(iocb, iter); +} + +ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + struct inode *inode = file_inode(iocb->ki_filp); + struct cifsInodeInfo *cinode = CIFS_I(inode); + ssize_t written; + int rc; + + if (iocb->ki_filp->f_flags & O_DIRECT) { + written = cifs_user_writev(iocb, from); + if (written > 0 && CIFS_CACHE_READ(cinode)) { + cifs_zap_mapping(inode); + cifs_dbg(FYI, + "Set no oplock for inode=%p after a write operation\n", + inode); + cinode->oplock = 0; + } + return written; + } + + written = cifs_get_writer(cinode); + if (written) + return written; + + written = generic_file_write_iter(iocb, from); + + if (CIFS_CACHE_WRITE(CIFS_I(inode))) + goto out; + + rc = filemap_fdatawrite(inode->i_mapping); + if (rc) + cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n", + rc, inode); + +out: + cifs_put_writer(cinode); + return written; +} + ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to) {