Received: by 10.192.165.148 with SMTP id m20csp768788imm; Fri, 27 Apr 2018 07:14:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqfevLomEt15pL5T8SxeWn0RI6Zins3F7DQXPd1TTiZU1fCg6ue6+IKljbSnFCKPfUpy+04 X-Received: by 2002:a65:52cc:: with SMTP id z12-v6mr2285184pgp.126.1524838481115; Fri, 27 Apr 2018 07:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838481; cv=none; d=google.com; s=arc-20160816; b=Kc7PVxegNCLLDNu36O9ktM3KvRxcrr74xXcEgFZTW/yYKz1pJIGsg6WyFeDJcH3V0W /WQwS8rfGcIJGEj+B9PokjJEBwV1hCjM+Xo91r99yYCpz+dpeBFwod4UXETB4MFb58iY OXGhvegyM/pfe8bDm9QKpz8rCb0WYSLpKpRqE4kXJL4MlhfpP5sM+UoBrAy8RsxXo57v OCTtVTXXqoGxgHPQR+8gbNykF+fv0C5mp7I0DKB4a7YFKqYVHqOcUdKdWO8KXMXoV6zd gA9U6DPkXxgShLgxgCvBlUpee9UZRC0Tvi2dbECDwzeWL1wrJmqucP57Nsrv3Yr1D5Bh KleQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=yE77Og4ci4bBmgDXS+j3pJ+3KLo+61RfJJM3DkTbmJA=; b=qlxWROLej3iKZ3vL1LHSWaotLHnsCkSY8WgwRtzgS/e6FqVkxqqUprj7IZWL1l1Clv PiRXPcZ0dL1BvvuU7DF95NO8Tjov3xEIVU8EmAsx3xkaUjL6k32/zxNmikqJlEQJTQAu Zv8+XPsmKmdXY5WTySer/AOp2BBtmIPV/z3lcAXL2MxBvUwEXS3EqVVxf2rrr1XT6pwx gChW1WMRyf+jOZWt5h4f+66FJU5aYBkQftiS/SqNUB0JWaiEq+XcUSmO2Ph+ugzoMk0u VO6hRT6B2nEEh4s7z0udb1n//+mApgM88iFEgUnqdK2X7NQDNPMvmCz7IY7jvnPr7N3I U/yA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si1299510pff.356.2018.04.27.07.14.27; Fri, 27 Apr 2018 07:14:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935286AbeD0ONF (ORCPT + 99 others); Fri, 27 Apr 2018 10:13:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:57434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935277AbeD0ONC (ORCPT ); Fri, 27 Apr 2018 10:13:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1761218BC; Fri, 27 Apr 2018 14:13:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1761218BC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Vivier , Jens Axboe , Stan Johnson , Finn Thain Subject: [PATCH 4.16 72/81] block/swim: Fix IO error at end of medium Date: Fri, 27 Apr 2018 15:59:14 +0200 Message-Id: <20180427135747.472667321@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain commit 5a13388d7aa1177b98d7168330ecbeeac52f844d upstream. Reading to the end of a 720K disk results in an IO error instead of EOF because the block layer thinks the disk has 2880 sectors. (Partly this is a result of inverted logic of the ONEMEG_MEDIA bit that's now fixed.) Initialize the density and head count in swim_add_floppy() to agree with the device size passed to set_capacity() during drive probe. Call set_capacity() again upon device open, after refreshing the density and head count values. Cc: Laurent Vivier Cc: Jens Axboe Cc: stable@vger.kernel.org # v4.14+ Tested-by: Stan Johnson Signed-off-by: Finn Thain Acked-by: Laurent Vivier Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/swim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -612,7 +612,6 @@ static void setup_medium(struct floppy_s struct floppy_struct *g; fs->disk_in = 1; fs->write_protected = swim_readbit(base, WRITE_PROT); - fs->type = swim_readbit(base, TWOMEG_MEDIA); if (swim_track00(base)) printk(KERN_ERR @@ -620,6 +619,9 @@ static void setup_medium(struct floppy_s swim_track00(base); + fs->type = swim_readbit(base, TWOMEG_MEDIA) ? + HD_MEDIA : DD_MEDIA; + fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2; get_floppy_geometry(fs, 0, &g); fs->total_secs = g->size; fs->secpercyl = g->head * g->sect; @@ -656,6 +658,8 @@ static int floppy_open(struct block_devi goto out; } + set_capacity(fs->disk, fs->total_secs); + if (mode & FMODE_NDELAY) return 0; @@ -808,10 +812,9 @@ static int swim_add_floppy(struct swim_p swim_motor(base, OFF); - if (swim_readbit(base, SINGLE_SIDED)) - fs->head_number = 1; - else - fs->head_number = 2; + fs->type = HD_MEDIA; + fs->head_number = 2; + fs->ref_count = 0; fs->ejected = 1;