source: gpfs_3.1_ker2.6.20/lpp/mmfs/samples/perf/irreg.h @ 73

Last change on this file since 73 was 16, checked in by rock, 17 years ago
File size: 5.9 KB
RevLine 
[16]1/* IBM_PROLOG_BEGIN_TAG                                                   */
2/* This is an automatically generated prolog.                             */
3/*                                                                        */
4/*                                                                        */
5/*                                                                        */
6/* Licensed Materials - Property of IBM                                   */
7/*                                                                        */
8/* (C) COPYRIGHT International Business Machines Corp. 1999,2004          */
9/* All Rights Reserved                                                    */
10/*                                                                        */
11/* US Government Users Restricted Rights - Use, duplication or            */
12/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
13/*                                                                        */
14/* IBM_PROLOG_END_TAG                                                     */
15
16/* Library to organize and optimize a sequence of accesses to an open file.
17   Usage is to first provide a list of n (file offset,length) pairs, then
18   call the pixXfer method n times to transfer the data.  Block prefetching is
19   taken care of under the covers by the library.  No locking is done, so all
20   accesses to or through the library are assumed to be single-threaded. */
21
22#include <sys/types.h>
23
24/* Definition of a single element in an access description list. */
25struct pixAccDesc
26{
27  offset_t off;
28  int len;
29};
30
31
32/* State variable for library.  Declare one of these for each open file
33   handle that will be used with this library and pass its address as the
34   first parameter to all of the pix... calls. */
35struct PrefetchedIrregularXfer
36{
37  /* File information.  File handle and block size for this file. */
38  int fHandle;
39  int blockSize;
40
41  /* Nonzero if pixXfer() calls should write, 0 for read */
42  int isWrite;
43
44  /* Pointer to description of accesses to be performed.  This is just a
45     pointer to the accDescP parameter of the last pixDeclareAccesses call. */
46  const struct pixAccDesc * accDescP;
47
48  /* Size of the accDescP array */
49  int nAccesses;
50
51  /* Access cursor.  Index of the element in the accDescP array that describes
52     the next transfer to be performed by the pixXfer() method. */
53  int nextAccessIndex;
54
55  /* Prefetch cursor.  Points to the next element in the accDescP array
56     that has not yet been included in the blockList array. */
57  int nextPrefetchIndex;
58
59  /* Description of blocks corresponding to byte ranges from accDescP.  A
60     byte range may translate into more than one block description. */
61#define MAX_BLOCKS 64
62  struct
63  {
64    offset_t blockNumber;   /* file block number (file offset / blockSize) */
65    int blkOffset;          /* offset in this block of the first byte that
66                               will be accessed */
67    int blkLen;             /* number of consecutive bytes in this block
68                               starting at offset that will be accessed */
69  } blockList[MAX_BLOCKS];
70
71  /* Description of entries in blockList that have been given to GPFS
72     and accepted using the multiple access range hint.  An empty list is
73     represented by setting nAcceptedBlockIndices to 0. */
74  int oldestAcceptedBlockIndex;
75  int nAcceptedBlockIndices;
76
77  /* Subset of the accepted blockList entries that need to be released
78     by the next multiple access range hint.  The first block to be released
79     is the one whose index is oldestAcceptedBlockIndex. */
80  int nReleaseBlockIndices;
81
82  /* Description of entries in blockList that have been generated from
83     entries in accDescP but not yet accepted by the GPFS multiple access
84     range hint.  If nPendingBlockIndices is > 0, then firstPendingBlockIndex
85     must equal oldestAcceptedBlockIndex+nAcceptedBlockIndices, with all
86     indices taken modulo MAX_BLOCKS. */
87  int firstPendingBlockIndex;
88  int nPendingBlockIndices;
89
90  /* Trace level.  A value of 0 does no tracing to stdout.  Higher values
91     trace more things. */
92  int verbosity;
93
94  /* Total number of blocks that have been accepted for prefetch minus
95     total number of blocks that have been released */
96  int netBlocksPrefetched;
97};
98
99
100/* Initialize (must be first call) */
101extern void pixInit(struct PrefetchedIrregularXfer * pixP);
102
103/* Declare the sequence of accesses that will be made by subsequent calls
104   to the pixXfer method.  The storage passed in will not be modified by
105   this class, but must not be deallocated by the caller until all pixXfer
106   calls have completed.  Returns an errno value on failure, or 0 if the
107   call is successful.  No access in accDescP may be longer than
108   MAX_ACCESS_BLOCKS times the block size of this file, or else pixXfer will
109   abort the access sequence and return an error. */
110#define MAX_ACCESS_BLOCKS 4
111extern int pixDeclareAccesses(struct PrefetchedIrregularXfer * pixP,
112                              int fHandle, int isWrite, int nAccesses,
113                              const struct pixAccDesc * accDescP);
114
115/* Perform the next read or write access defined by an earlier call to
116   pixDeclareAccesses.  The buffer is assumed to be large enough to contain
117   the next access from the previously declared list.  Returns an errno
118   value or zero as the function result.  If zero is returned, stores the
119   number of bytes transferred in *nBytesP. */
120extern int pixXfer(struct PrefetchedIrregularXfer * pixP, caddr_t bufP,
121                   int* nBytesP);
122
123/* Abort pending prefetches and release all prefetched blocks.  Returns
124   the state of the PrefetchedIrregularXfer object to what it was just
125   after calling pixInit(), except that verbosity is not reset. */
126extern void pixTerm(struct PrefetchedIrregularXfer * pixP);
127
128/* Set trace level.  A value of 0 does no tracing, while higher values
129   trace more stuff. */
130extern void pixSetTraceLevel(struct PrefetchedIrregularXfer * pixP, int level);
131
Note: See TracBrowser for help on using the repository browser.