Received: by 10.192.165.148 with SMTP id m20csp796778imm; Fri, 27 Apr 2018 07:40:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZraWdtVuNEUn7CbywiXJo8S0RawDi7EevjYlDBwPpITlJ9tfgVloFT7nP/YfOLi/XbSYk3o X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr2578206pla.328.1524840012320; Fri, 27 Apr 2018 07:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840012; cv=none; d=google.com; s=arc-20160816; b=Ejfo0+bKJHfgUYE3pbaH6DXLMnDvi2a6jtqrzHeo8ezv2X9a4uQOuON3WbUNNfcjLJ 9NdzMSY1ZjHDOdJhX99dcT1NqtgW8yxYWvNtFMBShb3wg0FfgQve6B9zfhDS6nKTRCok n6+UuNbpPuUkV9pIPW5bBP3Dey4aZ0PVH2+j6I1a2MUSuzxMBIt1XO+fXkyhnveg31NE j6qI7o8SWriHp72vsESb9HeExkRfYI2u1AfzE1ze3CBtSCSNtKIkKO3QSYgejhAKpRyT OiSJmRJIJUMNuSexuJNX2v/mExkOMofc9TWkNWh0WlVUIJy8j4StvCqLcX9s+rUVnKwv mPXw== 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=mnTE42RO6uqC3Z8kzHDr1PLvVIPTji5byX+/DKwf2CI=; b=XM09g9WnFzRr2a5abqNyyOi6zs6KF52oSyHt6lXhbH0LU2DBg344cMuYCmJxcLh9Lb yzy7KRl2LymPm9ml5O3934fQLtFgQdTJZn8A7sSkjXJk4C98HN3GhqnT6etMShezF1QK rlMAKLNzatXz5MzMVRgG7AN+rq08mN7lNtpxFfaSfiFJVZ+qxzKJQjdGliIjGRBkOx6H 6iPTABxF1AoqMWq5G4ctskMoDX3Ga1XJI9HJxtyPz+sMKjJ6d3VrspknH75i4OFCt3NL D+QnOHTV9vb7PVYUwwsTPFE+CHQpU2X64oKXMVghdbN7WtFulDq7+n/RDZl8esdNYOxz d6AA== 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 j7si56872pfh.3.2018.04.27.07.39.58; Fri, 27 Apr 2018 07:40:12 -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 S934650AbeD0OJU (ORCPT + 99 others); Fri, 27 Apr 2018 10:09:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934621AbeD0OJP (ORCPT ); Fri, 27 Apr 2018 10:09:15 -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 D194621892; Fri, 27 Apr 2018 14:09:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D194621892 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.14 75/80] block/swim: Fix IO error at end of medium Date: Fri, 27 Apr 2018 15:59:08 +0200 Message-Id: <20180427135736.814098386@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@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.14-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;