Public Member Functions | Protected Member Functions | Private Attributes

bea_TapeVolume Class Reference
[IVD Back-End Agent]

#include <bea_tapevolume.h>

Inheritance diagram for bea_TapeVolume:
Inheritance graph
[legend]
Collaboration diagram for bea_TapeVolume:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 bea_TapeVolume (scsi_IO *const a_scsiIO_p, bea_Medium *const a_medium_p, UInt32_t a_volNumber, UInt32_t a_size)
virtual UInt32_t GetPosition ()
virtual void Erase ()
virtual void WriteFileMarks (UInt32_t a_count=1)
virtual void Flush ()
virtual void SeekEOD ()
virtual void Rewind ()
virtual void SeekBlock (UInt32_t a_block)
virtual void SeekFileMark (Int32_t a_relativeFM)

Protected Member Functions

virtual ~bea_TapeVolume ()
virtual void WriteRaw (const UInt8_t *a_buf, UInt32_t a_size)
virtual void ReadRaw (UInt8_t *a_buf, UInt32_t a_size)
virtual void ReadEstimSizes ()
 Reads estimated overall and remaining capacity of this medium volume.

Private Attributes

 log_CLASSID_m
scsi_IO *const m_scsiIO_p

Detailed Description

Definition at line 46 of file bea_tapevolume.h.


Constructor & Destructor Documentation

bea_TapeVolume::bea_TapeVolume ( scsi_IO *const   a_scsiIO_p,
bea_Medium *const   a_medium_p,
UInt32_t  a_volNumber,
UInt32_t  a_size 
)

Definition at line 52 of file bea_tapevolume.cpp.

References log_FUNC_A_m.

  : bea_Volume(a_medium_p, a_volNumber, a_size),
    m_scsiIO_p(a_scsiIO_p) {

    log_FUNC_A_m(bea_TapeVolume,
        "num: " << a_volNumber << " size: " << a_size);
}

bea_TapeVolume::~bea_TapeVolume (  )  [protected, virtual]

Definition at line 66 of file bea_tapevolume.cpp.

References log_FUNC_m.


Member Function Documentation

void bea_TapeVolume::Erase (  )  [virtual]

Implements bea_Volume.

Definition at line 109 of file bea_tapevolume.cpp.

References ivd_BaseException::GetError(), ie_MEDIUM_MEDERR, bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), ivd_Error, log_FUNC_m, and m_scsiIO_p.

                           {
    log_FUNC_m(Erase);

    InvalidateSizes();
    try {
        cdb_Erase erase;
        m_scsiIO_p->IOCtl(erase);
    }
    catch(const ivd_Error &ie) {
        if (ie.GetError() == ie_MEDIUM_OVERFLOW) {
            log_MARKLINE_m;
            throw ivd_Error(ie_MEDIUM_MEDERR, "Volume overflow on erase.", true);
        }
        else {
            throw;
        }
    }

    InvalidateEOD();
}

Here is the call graph for this function:

void bea_TapeVolume::Flush (  )  [virtual]

Implements bea_Volume.

Definition at line 170 of file bea_tapevolume.cpp.

References log_FUNC_m, and WriteFileMarks().

Here is the call graph for this function:

UInt32_t bea_TapeVolume::GetPosition (  )  [virtual]

Implements bea_Volume.

Definition at line 72 of file bea_tapevolume.cpp.

References ivd_BaseException::GetError(), data_Position::GetPosition(), cdb_ReadPosition::GetPosition(), scsi_IO::IOCtl(), log_FUNC_m, m_scsiIO_p, and scsi_IO::WaitToBecomeReady().

Referenced by SeekEOD().

                                     {
    log_FUNC_m(GetPosition);
    cdb_ReadPosition  position;

    try {
        m_scsiIO_p->IOCtl(position);
    }
    catch (ivd_Error &ie) {
        if (ie.GetError() == ie_SCSI_NOT_READY) {
            m_scsiIO_p->WaitToBecomeReady();
            m_scsiIO_p->IOCtl(position);
        }
        else {
            throw;
        }
    }
    return position.GetPosition().GetPosition();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::ReadEstimSizes (  )  [protected, virtual]

Reads estimated overall and remaining capacity of this medium volume.

It stores the values so that they can be retrieved by Get* methods. This method converts sizes to MB.

Implements bea_Volume.

Definition at line 347 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Medium::GetCurVolNumber(), bea_Medium::GetMediumFamily(), data_Log::GetRemainingPartCap(), data_Log::GetTotalPartCap(), bea_Volume::GetVolumeNumber(), ie_INVALID_ARG, scsi_IO::IOCtl(), ivd_Error, log_DBG_m, log_FUNC_m, bea_Volume::m_atEOD, bea_Volume::m_medium_p, m_scsiIO_p, data_Log::pg_TAPECAP, SeekEOD(), and bea_Volume::SetEstimatedSizes().

                                    {
    log_FUNC_m(ReadEstimSizes);

    if (m_medium_p->GetCurVolNumber() != GetVolumeNumber()) {
        throw ivd_Error(
            ie_INVALID_ARG,
            "Estimated sizes can only be read for current volume.");
    };

    if (!m_atEOD) {
        SeekEOD();
    }

    data_Log        tapeCap(data_Log::pg_TAPECAP);
    cdb_LogSense    logSense(tapeCap);

    m_scsiIO_p->IOCtl(logSense);

    UInt32_t estimSize = tapeCap.GetTotalPartCap(UInt8_t(GetVolumeNumber())-1);
    UInt32_t estimFree = tapeCap.GetRemainingPartCap(UInt8_t(GetVolumeNumber())-1);

    if (m_medium_p->GetMediumFamily() != bmf_LTO) {
        // LTO reports capacity in MB, whereas other report in
        // kB. Conversion is necessary to convert the values to MB.
        estimSize /= 1024;
        estimFree /= 1024;
    };

    log_DBG_m(dbg_NORM,
        "Estimated capacity info [MB]:" << endl <<
        "total: " << estimSize << endl <<
        "free : " << estimFree << endl);

    SetEstimatedSizes(estimSize, estimFree);
}

Here is the call graph for this function:

void bea_TapeVolume::ReadRaw ( UInt8_t a_buf,
UInt32_t  a_size 
) [protected, virtual]

Implements bea_Volume.

Definition at line 101 of file bea_tapevolume.cpp.

References scsi_IO::IOCtl(), m_scsiIO_p, and cdb_Read::SetBuffer().

                                                            {
    cdb_Read   read;
    read.SetBuffer(a_buf, a_size);
    m_scsiIO_p->IOCtl(read);
}

Here is the call graph for this function:

void bea_TapeVolume::Rewind (  )  [virtual]

Implements bea_Volume.

Definition at line 264 of file bea_tapevolume.cpp.

References bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_FUNC_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, and scsi_IO::WaitToBecomeReady().

                            {
    log_FUNC_m(Rewind);

    if (DoMediumLogging()) {
        ostringstream sstr;
        sstr << "Vol " << GetVolumeNumber()
            << ": Rewind...";

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }

    InvalidateSizes();
    InvalidateEOD();

    cdb_Rewind rewind;

    try {
        m_scsiIO_p->IOCtl(rewind);
    }
    catch (ivd_Error &ie) {
        if (ie.GetError() == ie_SCSI_NOT_READY) {
            m_scsiIO_p->WaitToBecomeReady();
            m_scsiIO_p->IOCtl(rewind);
        }
        else {
            throw;
        }
    }
}

Here is the call graph for this function:

void bea_TapeVolume::SeekBlock ( UInt32_t  a_block  )  [virtual]

Implements bea_Volume.

Definition at line 224 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, cdb_Locate::SetBlockNum(), and scsi_IO::WaitToBecomeReady().

                                               {
    log_FUNC_A_m(SeekBlock, " blk: " << a_block);

    if (DoMediumLogging()) {
        ostringstream sstr;
        sstr << "Vol " << GetVolumeNumber()
            << ": Seeking to "<< a_block << "...";

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }

    InvalidateSizes();
    InvalidateEOD();

    cdb_Locate  pos;

    pos.SetBlockNum(a_block);
    try {
        m_scsiIO_p->IOCtl(pos);
    }
    catch (ivd_Error &ie) {
        if (ie.GetError() == ie_SCSI_NOT_READY) {
            m_scsiIO_p->WaitToBecomeReady();
            m_scsiIO_p->IOCtl(pos);
        }
        else if (ie.GetError() == ie_SCSI_EOM) {
            log_DBG_m(dbg_NORM,
                "Ignored early EOM when seeking to position.");
        }
        else {
            throw;
        }
    }
}

Here is the call graph for this function:

void bea_TapeVolume::SeekEOD (  )  [virtual]

Implements bea_Volume.

Definition at line 177 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), GetPosition(), bea_Volume::GetVolumeNumber(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, log_WriteEvent(), bea_Volume::m_atEOD, bea_Volume::m_medium_p, m_scsiIO_p, spaceEndOfData, and scsi_IO::WaitToBecomeReady().

Referenced by ReadEstimSizes().

                             {
    log_FUNC_m(SeekEOD);
    cdb_Space  eod(spaceEndOfData, 0);

    if (DoMediumLogging()) {
        ostringstream sstr;
        sstr << "Vol " << GetVolumeNumber()
            << ": Seeking to EOD...";

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }

    try {
        m_scsiIO_p->IOCtl(eod);
    }
    catch (ivd_Error &ie) {
        if (ie.GetError() == ie_SCSI_NOT_READY) {
            m_scsiIO_p->WaitToBecomeReady();
            m_scsiIO_p->IOCtl(eod);
        }
        else if (ie.GetError() == ie_SCSI_EOM) {
            log_DBG_m(dbg_NORM,
                "Ignored early EOM when seeking to EOD.");
        }
        else {
            throw;
        }
    }
    m_atEOD = true;

    if (DoMediumLogging()) {
        ostringstream sstr;
        sstr << "Vol " << GetVolumeNumber()
            << ": At EOD (" << GetPosition() << ")";

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::SeekFileMark ( Int32_t  a_relativeFM  )  [virtual]

Implements bea_Volume.

Definition at line 299 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, and spaceFileMarks.

                                                      {
    log_FUNC_A_m(SeekFileMark, "relativeFM: " << a_relativeFM);

    if (DoMediumLogging()) {
        ostringstream sstr;
        if (a_relativeFM > 0) {
            sstr
                << "Vol " << GetVolumeNumber()
                << ": Seeking " << a_relativeFM << " filemark(s) forward...";
        }
        else {
            sstr
                << "Vol " << GetVolumeNumber()
                << ": Seeking " << -a_relativeFM << " filemark(s) back...";
        }

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }

    InvalidateSizes();
    InvalidateEOD();

    cdb_Space fm(spaceFileMarks, a_relativeFM);
    try {
        m_scsiIO_p->IOCtl(fm);
    }
    catch(const ivd_Error& ie) {
        if (ie.GetError() == ie_SCSI_EOM) {
            log_DBG_m(dbg_NORM,
                      "Ignored early EOM when seeking to file mark.");
        }
        else {
            throw;
        }
    }
}

Here is the call graph for this function:

void bea_TapeVolume::WriteFileMarks ( UInt32_t  a_count = 1  )  [virtual]

Implements bea_Volume.

Definition at line 132 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_atEOD, bea_Volume::m_medium_p, and m_scsiIO_p.

Referenced by Flush().

                                                    {
    log_FUNC_A_m(WriteFileMarks, "count: " << a_count);

    if (DoMediumLogging()) {
        ostringstream sstr;
        sstr << "Vol " << GetVolumeNumber()
            << ": Writing filemark(s) "<< a_count << "...";

        log_WriteEvent(
            sstr.str(), "",
            GetJobID(),
            m_medium_p->GetBarcode());
    }

    InvalidateSizes();

    cdb_WriteFileMarks  fm(a_count);
    try {
        m_scsiIO_p->IOCtl(fm);
    }
    catch (const ivd_Error& ie) {
        if (ie.GetError() == ie_SCSI_EOM) {
            // File mark was written successfully.
            log_DBG_m(dbg_NORM,
                "Ignored early EOM when writing file marks.");
        }
        else {
            throw;
        }
    }

    if (a_count > 0) {
        m_atEOD = true;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::WriteRaw ( const UInt8_t a_buf,
UInt32_t  a_size 
) [protected, virtual]

Implements bea_Volume.

Definition at line 93 of file bea_tapevolume.cpp.

References scsi_IO::IOCtl(), m_scsiIO_p, and cdb_Write::SetBuffer().

                                                                   {
    cdb_Write   write;
    write.SetBuffer(a_buf, a_size);
    m_scsiIO_p->IOCtl(write);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from bea_Volume.

Definition at line 75 of file bea_tapevolume.h.


The documentation for this class was generated from the following files: