LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Borislav Petkov <petkovbb@googlemail.com>
To: <bzolnier@gmail.com>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
	Borislav Petkov <petkovbb@gmail.com>
Subject: [RFCPATCH 10/24] ide-tape: remove pipeline-specific code from idetape_chrdev_ioctl
Date: Sat,  1 Mar 2008 09:58:34 +0100	[thread overview]
Message-ID: <1204361928-30229-11-git-send-email-petkovbb@gmail.com> (raw)
In-Reply-To: <1204361928-30229-1-git-send-email-petkovbb@gmail.com>

The function used to compute the block_offset in order to write it
into mtget.mt_blkno, among others, by going over the stages still
present in the pipeline and adding the sectors left to submit in each
request. This was being done in idetape_pipeline_size() so remove it.
Since we do non-pipelined operation only, compute the offset now
from the sectors left to submit in the currently active request.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-tape.c |   39 +++++++++------------------------------
 1 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index dd11c7b..447b7b4 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2353,27 +2353,6 @@ static void idetape_pad_zeros(ide_drive_t *drive, int bcount)
 	}
 }
 
-static int idetape_pipeline_size(ide_drive_t *drive)
-{
-	idetape_tape_t *tape = drive->driver_data;
-	idetape_stage_t *stage;
-	struct request *rq;
-	int size = 0;
-
-	idetape_wait_for_pipeline(drive);
-	stage = tape->first_stage;
-	while (stage != NULL) {
-		rq = &stage->rq;
-		size += tape->blk_size * (rq->nr_sectors -
-				rq->current_nr_sectors);
-		if (rq->errors == IDETAPE_ERROR_FILEMARK)
-			size += tape->blk_size;
-		stage = stage->next;
-	}
-	size += tape->merge_stage_size;
-	return size;
-}
-
 /*
  * Rewinds the tape to the Beginning Of the current Partition (BOP). We
  * currently support only one partition.
@@ -2779,7 +2758,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
 
 /*
  * Our character device ioctls. General mtio.h magnetic io commands are
- * supported here, and not in the corresponding block interface. Our own
+ * supported here and not in the corresponding block interface. Our own
  * ide-tape ioctls are supported on both interfaces.
  */
 static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
@@ -2795,18 +2774,20 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
 
 	debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd);
 
-	tape->restart_speed_control_req = 1;
-	if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
-		idetape_empty_write_pipeline(drive);
+	if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
 		idetape_flush_tape_buffers(drive);
-	}
+
 	if (cmd == MTIOCGET || cmd == MTIOCPOS) {
-		block_offset = idetape_pipeline_size(drive) /
-			(tape->blk_size * tape->user_bs_factor);
+		struct request *rq = tape->active_data_rq;
+
+		block_offset = (rq->nr_sectors - rq->current_nr_sectors) /
+			       (tape->blk_size * tape->user_bs_factor);
+
 		position = idetape_read_position(drive);
 		if (position < 0)
 			return -EIO;
 	}
+
 	switch (cmd) {
 	case MTIOCTOP:
 		if (copy_from_user(&mtop, argp, sizeof(struct mtop)))
@@ -2832,8 +2813,6 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
 			return -EFAULT;
 		return 0;
 	default:
-		if (tape->chrdev_dir == IDETAPE_DIR_READ)
-			idetape_discard_read_pipeline(drive, 1);
 		return idetape_blkdev_ioctl(drive, cmd, arg);
 	}
 }
-- 
1.5.4.1


  parent reply	other threads:[~2008-03-01  9:01 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-01  8:58 [PATCH 00/24] ide-tape: remove pipelined mode operation Borislav Petkov
2008-03-01  8:58 ` [PATCH 01/24] ide-tape: remove idetape_pipeline_active() Borislav Petkov
2008-03-02 18:21   ` Bartlomiej Zolnierkiewicz
2008-03-01  8:58 ` [PATCH 02/24] ide-tape: remove pipeline-specific code from idetape_add_chrdev_write_request Borislav Petkov
2008-03-02 18:33   ` Bartlomiej Zolnierkiewicz
2008-03-02 21:19     ` Borislav Petkov
2008-03-02 23:16       ` Bartlomiej Zolnierkiewicz
2008-03-03  6:43         ` Borislav Petkov
2008-03-03 22:32           ` Bartlomiej Zolnierkiewicz
2008-03-01  8:58 ` [PATCH 03/24] ide-tape: remove pipeline-specific code from idetape_add_chrdev_read_request Borislav Petkov
2008-03-02 18:36   ` Bartlomiej Zolnierkiewicz
2008-03-02 21:28     ` Borislav Petkov
2008-03-01  8:58 ` [PATCH 04/24] ide-tape: remove pipeline-specific code from idetape_chrdev_write Borislav Petkov
2008-03-02 18:41   ` Bartlomiej Zolnierkiewicz
2008-03-02 21:31     ` Borislav Petkov
2008-03-02 23:17       ` Bartlomiej Zolnierkiewicz
2008-03-01  8:58 ` [PATCH 05/24] ide-tape: cleanup pipeline-specific code from idetape_init_read Borislav Petkov
2008-03-02 18:48   ` Bartlomiej Zolnierkiewicz
2008-03-01  8:58 ` [PATCH 06/24] ide-tape: remove unused stage-parameter from idetape_copy_stage_to_user Borislav Petkov
2008-03-02 19:15   ` Bartlomiej Zolnierkiewicz
2008-03-01  8:58 ` [PATCH 07/24] ide-tape: remove pipeline-specific code bits from idetape_chrdev_read Borislav Petkov
2008-03-01  8:58 ` [PATCH 08/24] ide-tape: remove pipeline-specific code from idetape_space_over_filemarks Borislav Petkov
2008-03-01  8:58 ` [PATCH 09/24] ide-tape: remove pipeline-specific code from idetape_mtioctop Borislav Petkov
2008-03-01  8:58 ` Borislav Petkov [this message]
2008-03-01  8:58 ` [PATCH 11/24] ide-tape: remove pipeline-specific code from idetape_blkdev_ioctl Borislav Petkov
2008-03-01  8:58 ` [PATCH 12/24] ide-tape: remove idetape_empty_write_pipeline Borislav Petkov
2008-03-01  8:58 ` [PATCH 13/24] ide-tape: remove pipeline-specific code from idetape_chrdev_release Borislav Petkov
2008-03-01  8:58 ` [PATCH 14/24] ide-tape: remove __idetape_discard_read_pipeline Borislav Petkov
2008-03-01  8:58 ` [PATCH 15/24] ide-tape: remove pipeline-specific code from idetape_end_request Borislav Petkov
2008-03-01  8:58 ` [PATCH 16/24] ide-tape: remove idetape_calculate_speeds Borislav Petkov
2008-03-01  8:58 ` [PATCH 17/24] ide-tape: remove pipeline-specific code from idetape_chrdev_open Borislav Petkov
2008-03-01  8:58 ` [PATCH 18/24] ide-tape: remove pipeline-specific code from idetape_setup Borislav Petkov
2008-03-01  8:58 ` [PATCH 19/24] ide-tape: remove pipelined mode parameters Borislav Petkov
2008-03-01  8:58 ` [PATCH 20/24] ide-tape: remove pipelined mode tape control flags Borislav Petkov
2008-03-01  8:58 ` [PATCH 21/24] ide-tape: remove pipeline-specific members from struct ide_tape_obj Borislav Petkov
2008-03-01  8:58 ` [PATCH 22/24] ide-tape: remove misc references to pipelined operation in the comments Borislav Petkov
2008-03-01  8:58 ` [PATCH 23/24] ide-tape: remove pipelined mode description from Documentation/ide/ide-tape.txt Borislav Petkov
2008-03-01  8:58 ` [PATCH 24/24] ide-tape: remove comments markup " Borislav Petkov
2008-03-01  9:55 ` [PATCH 00/24] ide-tape: remove pipelined mode operation Jens Axboe
2008-03-01 15:45   ` Borislav Petkov
2008-03-01 18:36     ` Jens Axboe
2008-03-01 10:20 ` Adrian Bunk
2008-03-01 15:37   ` Borislav Petkov
2008-03-22 16:09     ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1204361928-30229-11-git-send-email-petkovbb@gmail.com \
    --to=petkovbb@googlemail.com \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    --subject='Re: [RFCPATCH 10/24] ide-tape: remove pipeline-specific code from idetape_chrdev_ioctl' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).