From patchwork Tue May 9 11:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13235655 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 053F1C7EE24 for ; Tue, 9 May 2023 11:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235556AbjEILtF (ORCPT ); Tue, 9 May 2023 07:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235544AbjEILtE (ORCPT ); Tue, 9 May 2023 07:49:04 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F394D40E9 for ; Tue, 9 May 2023 04:49:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7349F21907 for ; Tue, 9 May 2023 11:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1683632941; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aKahlhyMyeHq92SQH9VXS87C+RYF8Xti1KK9MdntUeA=; b=YjIra+g1lkICx1GYEwlCP1iT8akvNxB9zKAu45XpM0Kvhop76kQ/1ahKfxwAebMTAQanRR YSYCekvKvcLtPw48visl6OLFdGC450zbnTMrBMkCCx3vuzTlKVlX22yQMLsxCPaDNg6Vyb LjTv7xxZyKmjwN0HbcsqDMizYW1KVoM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B67C6139B3 for ; Tue, 9 May 2023 11:49:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8D6yHiwzWmQSMwAAMHmgww (envelope-from ) for ; Tue, 09 May 2023 11:49:00 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/3] btrfs-progs: constify the buffer pointer for write functions Date: Tue, 9 May 2023 19:48:39 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The following functions accept a buffer for write, which can be marked as const: - btrfs_pwrite() - write_data_to_disk() Signed-off-by: Qu Wenruo --- common/device-utils.h | 6 +++--- kernel-shared/extent_io.c | 2 +- kernel-shared/extent_io.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/device-utils.h b/common/device-utils.h index 6390a72951eb..21955c2835f2 100644 --- a/common/device-utils.h +++ b/common/device-utils.h @@ -54,7 +54,7 @@ ssize_t btrfs_direct_pread(int fd, void *buf, size_t count, off_t offset); ssize_t btrfs_direct_pwrite(int fd, const void *buf, size_t count, off_t offset); #ifdef BTRFS_ZONED -static inline ssize_t btrfs_pwrite(int fd, void *buf, size_t count, +static inline ssize_t btrfs_pwrite(int fd, const void *buf, size_t count, off_t offset, bool direct) { if (!direct) @@ -62,8 +62,8 @@ static inline ssize_t btrfs_pwrite(int fd, void *buf, size_t count, return btrfs_direct_pwrite(fd, buf, count, offset); } -static inline ssize_t btrfs_pread(int fd, void *buf, size_t count, off_t offset, - bool direct) +static inline ssize_t btrfs_pread(int fd, void *buf, size_t count, + off_t offset, bool direct) { if (!direct) return pread(fd, buf, count, offset); diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c index 172ba66a1cfa..7f6d592ab641 100644 --- a/kernel-shared/extent_io.c +++ b/kernel-shared/extent_io.c @@ -477,7 +477,7 @@ int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 logical, * Such data will be written to all mirrors and RAID56 P/Q will also be * properly handled. */ -int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset, +int write_data_to_disk(struct btrfs_fs_info *info, const void *buf, u64 offset, u64 bytes) { struct btrfs_multi_bio *multi = NULL; diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h index a1cda3a53351..b6c30eef67c2 100644 --- a/kernel-shared/extent_io.h +++ b/kernel-shared/extent_io.h @@ -128,7 +128,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb); int btrfs_clear_buffer_dirty(struct extent_buffer *eb); int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 logical, u64 *len, int mirror); -int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset, +int write_data_to_disk(struct btrfs_fs_info *info, const void *buf, u64 offset, u64 bytes); void extent_buffer_bitmap_clear(struct extent_buffer *eb, unsigned long start, unsigned long pos, unsigned long len);