From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751798AbcFWVSt (ORCPT ); Thu, 23 Jun 2016 17:18:49 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:36212 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbcFWVSr (ORCPT ); Thu, 23 Jun 2016 17:18:47 -0400 Date: Thu, 23 Jun 2016 17:18:45 -0400 From: Tejun Heo To: Konstantin Khlebnikov Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, NeilBrown , stable@vger.kernel.org Subject: Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Message-ID: <20160623211845.GL3262@mtj.duckdns.org> References: <146662093622.3726.10220135910756738018.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <146662093622.3726.10220135910756738018.stgit@buzz> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 22, 2016 at 09:42:16PM +0300, Konstantin Khlebnikov wrote: > Attributes declared with __ATTR_PREALLOC use sysfs_kf_read() which returns > zero bytes for non-zero offset. This breaks script checkarray in mdadm tool > in debian where /bin/sh is 'dash' because its builtin 'read' reads only one > byte at a time. Script gets 'i' instead of 'idle' when reads current action > from /sys/block/$dev/md/sync_action and as a result does nothing. > > This patch adds trivial implementation of partial read: generate whole > string and move required part into buffer head. > > Signed-off-by: Konstantin Khlebnikov > Fixes: 4ef67a8c95f3 ("sysfs/kernfs: make read requests on pre-alloc files use the buffer.") > Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787950 > Cc: Stable # v3.19+ Acked-by: Tejun Heo Thanks. -- tejun