From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD6B9C4338F for ; Thu, 5 Aug 2021 04:35:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C10EF61004 for ; Thu, 5 Aug 2021 04:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236424AbhHEEfa (ORCPT ); Thu, 5 Aug 2021 00:35:30 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:44768 "EHLO mail-pl1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236329AbhHEEf0 (ORCPT ); Thu, 5 Aug 2021 00:35:26 -0400 Received: by mail-pl1-f181.google.com with SMTP id q2so5569144plr.11 for ; Wed, 04 Aug 2021 21:35:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zqkxRlYr87kbKQ9r71+y8bsBamGsVypc9m9RJrJLvrI=; b=im4Rp2hMfq7ouMFunxqxqlgPQ6rHKP3JgSMvMmmfoOI8/7T3BPQFeYUB6+CwjlG+Dv 9XStpl+DNruQz54RY6eOiF1EqW+f492hwTBbbxdPT84elarT47Bcax0mWBurSb9/aAhh Hk+1wX2Cf9pA96ZqJCjey3uM41qr92nZIK7LZm7po4wHUgngca5XzfZCmz0iB0EYsPbD lpnQvz4jR4xCTaiCSoqy9dr2XlQmosSgMDwMxLGvmD3JEeqS7KF+ki9/4yO5qgoxMOBC sGVDWhMbpfKGl4sGfZzdt+fW65gUOUCSdj4mVXrWok9fcnkpTrJHHLN8ogaqZcDK4wyG jZUQ== X-Gm-Message-State: AOAM530pbRBqHedj8Fl4fmOLmhX/FXGUishLcajdqa+4MnRXwT8V/tLo +f0g5Hu3i3O0ACdVtjzsCN0= X-Google-Smtp-Source: ABdhPJxO9FxtHheSPC4QGlfyRxUjwuXmOlUY3XMIwkCOcoDEkyD76HpRSLGCN0Tq44QDOVjOiJoy1g== X-Received: by 2002:aa7:96aa:0:b029:3c3:9e84:45a3 with SMTP id g10-20020aa796aa0000b02903c39e8445a3mr3066167pfk.23.1628138112195; Wed, 04 Aug 2021 21:35:12 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:e365:91b7:6284:3848]) by smtp.gmail.com with ESMTPSA id b15sm5642153pgj.60.2021.08.04.21.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 21:35:11 -0700 (PDT) From: Bart Van Assche To: Christoph Hellwig Cc: Joel Becker , linux-kernel@vger.kernel.org, Bodo Stroesser , "Martin K . Petersen" , Brendan Higgins , Bart Van Assche , Yanko Kaneti Subject: [PATCH v4 1/3] configfs: Restore the kernel v5.13 text attribute write behavior Date: Wed, 4 Aug 2021 21:35:01 -0700 Message-Id: <20210805043503.20252-2-bvanassche@acm.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805043503.20252-1-bvanassche@acm.org> References: <20210805043503.20252-1-bvanassche@acm.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of appending new text attribute data at the offset specified by the write() system call, only pass the newly written data to the .store() callback. Cc: Bodo Stroesser Cc: Martin K. Petersen Cc: Yanko Kaneti Cc: Brendan Higgins Reported-by: Bodo Stroesser Tested-by: Bodo Stroesser Signed-off-by: Bart Van Assche --- fs/configfs/file.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/fs/configfs/file.c b/fs/configfs/file.c index 5a0be9985bae..0ad32150611e 100644 --- a/fs/configfs/file.c +++ b/fs/configfs/file.c @@ -177,28 +177,22 @@ static ssize_t configfs_bin_read_iter(struct kiocb *iocb, struct iov_iter *to) return retval; } -/* Fill [buffer, buffer + pos) with data coming from @from. */ -static int fill_write_buffer(struct configfs_buffer *buffer, loff_t pos, +/* Fill @buffer with data coming from @from. */ +static int fill_write_buffer(struct configfs_buffer *buffer, struct iov_iter *from) { - loff_t to_copy; int copied; - u8 *to; if (!buffer->page) buffer->page = (char *)__get_free_pages(GFP_KERNEL, 0); if (!buffer->page) return -ENOMEM; - to_copy = SIMPLE_ATTR_SIZE - 1 - pos; - if (to_copy <= 0) - return 0; - to = buffer->page + pos; - copied = copy_from_iter(to, to_copy, from); + copied = copy_from_iter(buffer->page, SIMPLE_ATTR_SIZE - 1, from); buffer->needs_read_fill = 1; /* if buf is assumed to contain a string, terminate it by \0, * so e.g. sscanf() can scan the string easily */ - to[copied] = 0; + buffer->page[copied] = 0; return copied ? : -EFAULT; } @@ -227,10 +221,10 @@ static ssize_t configfs_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; struct configfs_buffer *buffer = file->private_data; - ssize_t len; + int len; mutex_lock(&buffer->mutex); - len = fill_write_buffer(buffer, iocb->ki_pos, from); + len = fill_write_buffer(buffer, from); if (len > 0) len = flush_write_buffer(file, buffer, len); if (len > 0)