Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:37

0001 #ifndef __XRDOSS_VS_H__
0002 #define __XRDOSS_VS_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                           X r d O s s V S . h h                            */
0006 /*                                                                            */
0007 /* (c) 2020 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 /******************************************************************************/
0034 /*                    C l a s s   X r d O s s V S P a r t                     */
0035 /******************************************************************************/
0036   
0037 //-----------------------------------------------------------------------------
0038 //! Class describing the patitions associated with a space. This is returned
0039 //! as a vector by StatVS() when so requested. Note that pPath points to a path
0040 //! associated with the partition. No inference should be made about this
0041 //! path other than it is one of, perhaps of many, paths associated with the
0042 //! partition. The aPath vector provides specific paths that are associated
0043 //! with allocated files in the partition relative to the space name. There
0044 //! may be many of these for the partition. The vector always ends with a nil
0045 //! pointer.
0046 //!
0047 //! The bdevID is a unique identifier for each block device. It is currently
0048 //! only supported in Linux. Other systems assign all partitions the generic ID
0049 //! of 0. Even in Linux, the ID will be zero for softwared devices (though not
0050 //! for LVM devices backed by a real device). Softwared devices such as
0051 //! distributed file systems cannot be identified correctly as they do not
0052 //! provide sufficiently distinguishing information.
0053 //!
0054 //! The partID is an ascending value that uniquely identifies a partition
0055 //! irrespective of its associated bdevID. However, using this information to
0056 //! schedule read/write requests is not trivial and may overwhelm the
0057 //! underlying device if it has many partitions. You can check if the system
0058 //! correctly identified all devices using DevID(0,x,y). If 'x' is one upon
0059 //! return, then using partID for scheduling is the only recourse as either
0060 //! no real devices were found or the system only has one such device.
0061 //-----------------------------------------------------------------------------
0062 
0063 class XrdOssVSPart
0064 {
0065 public:
0066 const char    *pPath;   // Valid path to partition (not the allocation path)
0067 const char   **aPath;   // Allocation root paths for this partition
0068 long long      Total;   // Total bytes
0069 long long      Free;    // Total bytes free
0070 unsigned short bdevID;  // Device    unique ID (bdevs may have many partitions)
0071 unsigned short partID;  // Partition unique ID (parts may have the same bdevID)
0072 int            rsvd1;
0073 void          *rsvd2;   // Reserved
0074 
0075                XrdOssVSPart() : pPath(0),  aPath(0), Total(0), Free(0),
0076                                 bdevID(0), partID(0), rsvd1(0), rsvd2(0)
0077                               {}
0078               ~XrdOssVSPart() {}
0079 };
0080 
0081 /******************************************************************************/
0082 /*                    C l a s s   X r d O s s V S I n f o                     */
0083 /******************************************************************************/
0084   
0085 // Class passed to StatVS()
0086 //
0087 class XrdOssVSInfo
0088 {
0089 public:
0090 long long     Total;   // Total bytes
0091 long long     Free;    // Total bytes free
0092 long long     Large;   // Total bytes in largest partition
0093 long long     LFree;   // Max   bytes free in contiguous chunk
0094 long long     Usage;   // Used  bytes (if usage enabled)
0095 long long     Quota;   // Quota bytes (if quota enabled)
0096 int           Extents; // Number of partitions/extents
0097 int           Reserved;
0098 XrdOssVSPart *vsPart;  // Partition info as vsPart[extents] may be nil
0099 
0100 //-----------------------------------------------------------------------------
0101 //! Export the partition table to avoid deletion when this object goes
0102 //! out of scope.
0103 //!
0104 //! @param  nParts - Reference to where the number of partitions is stored/
0105 //!
0106 //! @return Pointer to the partion vector. You are responsible for deletion
0107 //!         using "delete [] <prt>".
0108 //-----------------------------------------------------------------------------
0109 
0110 XrdOssVSPart *Export(int &nParts)
0111                     {XrdOssVSPart *pVec = vsPart;
0112                      vsPart = 0;
0113                      nParts = Extents;
0114                      return pVec;
0115                     }
0116 
0117               XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
0118                                Quota(-1),Extents(0),Reserved(0), vsPart(0) {}
0119              ~XrdOssVSInfo() {if (vsPart) delete [] vsPart;}
0120 };
0121 #endif