[stgt] [PATCH 07/15] tgt: os.h: sync_file_range is OS dependent
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Mon Mar 2 08:08:40 CET 2009
On Sun, 1 Mar 2009 18:50:42 +0200
Boaz Harrosh <bharrosh at panasas.com> wrote:
> Introduce a new header that includes definitions of all
> OS specific services. stgt code will use abstract API from
> os.h. (start with os_xxx). Then a linux/os.c and bsd/os.c
> implement these services for the needed platform.
>
> First such service is sync_file_range which needs to be
> emulated in bsd.
>
> Signed-off-by: Boaz Harrosh <bharrosh at panasas.com>
> ---
> usr/Makefile | 3 +++
> usr/bs_mmap.c | 2 +-
> usr/bs_rdwr.c | 2 +-
> usr/bsd/os.c | 24 ++++++++++++++++++++++++
> usr/linux/os.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> usr/os.h | 13 +++++++++++++
> usr/util.h | 38 +-------------------------------------
> 7 files changed, 88 insertions(+), 39 deletions(-)
> create mode 100644 usr/bsd/os.c
> create mode 100644 usr/linux/os.c
> create mode 100644 usr/os.h
>
> diff --git a/usr/Makefile b/usr/Makefile
> index 3fc848e..03b3c90 100644
> --- a/usr/Makefile
> +++ b/usr/Makefile
> @@ -65,6 +65,9 @@ TGTD_OBJS += tgtd.o mgmt.o target.o scsi.o log.o driver.o util.o work.o \
> parser.o spc.o sbc.o mmc.o osd.o scc.o smc.o \
> ssc.o bs_ssc.o libssc.o \
> bs_null.o bs_sg.o bs.o libcrc32c.o
> +
> +TGTD_OBJS += linux/os.o
> +
> MANPAGES = ../doc/manpages/tgtadm.8 ../doc/manpages/tgt-admin.8 \
> ../doc/manpages/tgt-setup-lun.8
> DOCS = ../doc/README.fcoe ../doc/README.ibmvstgt ../doc/README.iscsi ../doc/README.iser \
> diff --git a/usr/bs_mmap.c b/usr/bs_mmap.c
> index bb24f5e..8eb6a47 100644
> --- a/usr/bs_mmap.c
> +++ b/usr/bs_mmap.c
> @@ -60,7 +60,7 @@ static void bs_mmap_request(struct scsi_cmd *cmd)
> unsigned int flags =
> SYNC_FILE_RANGE_WAIT_BEFORE| SYNC_FILE_RANGE_WRITE;
>
> - ret = __sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
> + ret = os_sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
> if (ret) {
> result = SAM_STAT_CHECK_CONDITION;
> key = MEDIUM_ERROR;
> diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c
> index 65a6136..0c21e01 100644
> --- a/usr/bs_rdwr.c
> +++ b/usr/bs_rdwr.c
> @@ -51,7 +51,7 @@ static void bs_sync_sync_range(struct scsi_cmd *cmd, uint32_t length,
> int ret;
> unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE| SYNC_FILE_RANGE_WRITE;
>
> - ret = __sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
> + ret = os_sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
> if (ret)
> set_medium_error(result, key, asc);
> }
> diff --git a/usr/bsd/os.c b/usr/bsd/os.c
> new file mode 100644
> index 0000000..f24f515
> --- /dev/null
> +++ b/usr/bsd/os.c
> @@ -0,0 +1,24 @@
> +/*
> +* os.c: OS dependent services implementation on BSD platform
Please drop the file name. It's pointless.
> +* Description:
> +* Implements these services in os.h on the BSD platform
This just looks unnecessary. Please kill it.
> +* Author: Boaz Harrosh <bharrosh at panasas.com>, (C) 2009
> +*
> +* Copyright: See COPYING file that comes with this distribution
Please use the style consistent with the other files.
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list