[PATCH] SSC: dont fsync() on each written block. Do one single fsync() when file is closed in FILEMARK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tomo, list,

Please find attached a patch to SSC which changes when it performs fsync().
With this patch fsync will not be called for normal block writes but
only for the final "write a filemark" that is issued when a full
session writing to the tape has finished.

The patch does improve performance significantly, especially on
slow/low-end/dodgy hardware where fsync is expensive.

As for data safety, I think this is ok.
We dont guarantee that the data is all destaged to physical media
until WRITE-FILEMARK command has completed successfully.

Imho if the system crashes during the write session but before it has
completed (==WRITE-FILEMARK) then all bets are off ?

Maybe Mark and some of the other tape people can speak up if this is
valid or dodgy reasoning?
If so maybe I could add a attribute "buffered write = Yes|No" where
fsync() on every write vs fsync() one the backup is complete
can be controlled.

Performance improvement is significant on slow hw!

ronnie sahlberg

Attachment: 0001-SSC-dont-do-fsync-on-every-write-only-fsync-at-the-e.patch.gz
Description: GNU Zip compressed data

From b77200c7c9fc4805d2fa317a624e6f7c5090eb5f Mon Sep 17 00:00:00 2001
From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
Date: Sat, 21 Jan 2012 16:39:34 +1100
Subject: [PATCH] SSC: dont do fsync() on every write, only fsync() at the end of the backup when we write a filemark

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
 usr/bs_ssc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/usr/bs_ssc.c b/usr/bs_ssc.c
index 469057d..f21509c 100644
--- a/usr/bs_ssc.c
+++ b/usr/bs_ssc.c
@@ -189,7 +189,8 @@ static int append_blk(struct scsi_cmd *cmd, uint8_t *data,
 	/* Write new EOD blk header */
-	fsync(fd);
+	if (type == BLK_FILEMARK)
+		fsync(fd);
 	return SAM_STAT_GOOD;

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [XFree86]
  Powered by Linux