Villalovos, John L
2004-Aug-02 13:14 UTC
[Ocfs2-devel] Calculating volume size from superblock
Another simple question. How do I calculate the size of the volume from the superblock? Do I just use the two fields: u_int32_t s_blocksize_bits; /* Blocksize for this fs */ u_int32_t s_clustersize_bits; /* Clustersize for this fs */ What is the formula to use? Thanks, John
superblock has the clustersize and global bitmap has the number of bits. clustersize ==> 17 bits ==> 128K 128K x 200059 bits = 24G This size is the total size of the disk. [root@ca-test6-RHAS21 sunil]# ./debugfs.ocfs2 /dev/sde2 debugocfs version 0.0.1 Bound /dev/sde2 to /dev/raw/raw3 debugfs: stats Revision: 0.90 Mount Count: 0 Max Mount Count: 20 State: 0 Errors: 0 Check Interval: 0 Last Check: Tue Jul 20 09:22:50 2004 Creator OS: 0 Feature Compat: 0 Incompat: 0 RO Compat: 0 Root Blknum: 3 System Dir Blknum: 4 Block Size Bits: 12 Cluster Size Bits: 17 <==== Max Nodes: 3 Label: oastdbf2 UUID: F2F0828734DEFB36D0B9DEBC10840971 Inode: 2 Mode: 00 Generation: 0 Type: unknown Flags: valid system superblock User: 0 (root) Group: 0 (root) Size: 0 Links: 0 Clusters: 0 Lock Master: 0 Level: 0x0 Seqnum: 0 Lock Map: 000 ctime: 0x40fd46da -- Tue Jul 20 09:22:50 2004 atime: 0x0 -- Wed Dec 31 16:00:00 1969 mtime: 0x40fd46da -- Tue Jul 20 09:22:50 2004 dtime: 0x0 -- Wed Dec 31 16:00:00 1969 Last Extblk: 0 Sub Alloc Node: 4294967295 Sub Alloc Blknum: 2 debugfs: stat 9 Inode: 9 Mode: 0775 Generation: 0 Type: regular Flags: valid system allocbitmap User: 1011 (oracle) Group: 1011 (oracle) Size: 131072 Links: 1 Clusters: 1 Lock Master: 0 Level: 0x5 Seqnum: 0 Lock Map: 000 ctime: 0x40fd46da -- Tue Jul 20 09:22:50 2004 atime: 0x40fd46da -- Tue Jul 20 09:22:50 2004 mtime: 0x40fd46da -- Tue Jul 20 09:22:50 2004 dtime: 0x0 -- Wed Dec 31 16:00:00 1969 Last Extblk: 0 Sub Alloc Node: 4294967295 Sub Alloc Blknum: 9 ===> Bitmap Total: 200059 Used: 72197 Clear: 127862 Tree Depth: 0 Count: 243 Next Free Rec: 1 ## File Offset Num Clusters Disk Offset 0 0 1 3744 debugfs: ls 4 Inode Rlen Nlen Ty Name 224 16 1 2 . 224 16 2 2 .. 5 24 10 1 bad_blocks 6 32 18 1 global_inode_alloc 7 40 25 1 global_inode_alloc_bitmap 8 16 3 1 dlm 9 28 13 1 global_bitmap 10 24 10 2 orphan_dir 11 32 17 1 extent_alloc:0000 12 32 17 1 extent_alloc:0001 13 32 17 1 extent_alloc:0002 14 36 24 1 extent_alloc_bitmap:0000 15 36 24 1 extent_alloc_bitmap:0001 16 36 24 1 extent_alloc_bitmap:0002 17 28 16 1 inode_alloc:0000 18 28 16 1 inode_alloc:0001 19 28 16 1 inode_alloc:0002 20 36 23 1 inode_alloc_bitmap:0000 21 36 23 1 inode_alloc_bitmap:0001 22 36 23 1 inode_alloc_bitmap:0002 23 24 12 1 journal:0000 24 24 12 1 journal:0001 25 24 12 1 journal:0002 26 28 16 1 local_alloc:0000 27 28 16 1 local_alloc:0001 28 3376 16 1 local_alloc:0002 debugfs: On Mon, 2004-08-02 at 11:13, Villalovos, John L wrote:> Another simple question. > > How do I calculate the size of the volume from the superblock? > > Do I just use the two fields: > > u_int32_t s_blocksize_bits; /* Blocksize for this fs */ > u_int32_t s_clustersize_bits; /* Clustersize for this fs */ > > What is the formula to use? > > Thanks, > John > _______________________________________________ > Ocfs2-devel mailing list > Ocfs2-devel@oss.oracle.com > http://oss.oracle.com/mailman/listinfo/ocfs2-devel
On Mon, Aug 02, 2004 at 11:13:46AM -0700, Villalovos, John L wrote:> How do I calculate the size of the volume from the superblock? > > Do I just use the two fields: > > u_int32_t s_blocksize_bits; /* Blocksize for this fs */ > u_int32_t s_clustersize_bits; /* Clustersize for this fs */ > > What is the formula to use?As Sunil pointed out, you need to use the global bitmap to determine the number of clusters and multiply it by the clustersize. The libocfs2 library can help you get that information, or you can code up the bits to parse the information yourself. Doing it yourself means learning how to navigate directories. Joel -- "Sometimes I think the surest sign intelligent life exists elsewhere in the universe is that none of it has tried to contact us." -Calvin & Hobbes Joel Becker Senior Member of Technical Staff Oracle Corporation E-mail: joel.becker@oracle.com Phone: (650) 506-8127
Villalovos, John L
2004-Aug-02 13:56 UTC
[Ocfs2-devel] Calculating volume size from superblock
joel.becker@oracle.com wrote:> As Sunil pointed out, you need to use the global bitmap to > determine the number of clusters and multiply it by the clustersize. > The libocfs2 library can help you get that information, or > you can code > up the bits to parse the information yourself. Doing it > yourself means > learning how to navigate directories.So it sounds like it isn't a simple thing to do? How portable is the libocfs2 library? Is it fairly self contained? Wondering if I should copy the whole library over to EVMS. They are GPL and so is the ocfstools package so the licensing is no problem. John
Villalovos, John L
2004-Aug-02 17:01 UTC
[Ocfs2-devel] Calculating volume size from superblock
joel.becker@oracle.com wrote:> As Sunil pointed out, you need to use the global bitmap to > determine the number of clusters and multiply it by the clustersize. > The libocfs2 library can help you get that information, or > you can code > up the bits to parse the information yourself. Doing it > yourself means > learning how to navigate directories.Just wondering. As a possible RFE. Is there any reason the size of the global bitmap could not be in the superblock? It seems strange that in order to find out how big the filesystem is I have to actually traverse the filesystem. Would it be a bad to but the size of the global bitmap into the superblock? Thanks, John
Villalovos, John L
2004-Aug-03 14:14 UTC
[Ocfs2-devel] Calculating volume size from superblock
joel.becker@oracle.com wrote:> On Mon, Aug 02, 2004 at 03:00:44PM -0700, Villalovos, John L wrote: >> Just wondering. As a possible RFE. Is there any reason the size of >> the global bitmap could not be in the superblock? It seems strange >> that in order to find out how big the filesystem is I have to >> actually traverse the filesystem. > > Well, the global bitmap is what the global bitmap represents, if > you'll allow circular logic. Why should the superblock need to be > updated if global bitmap information changes? This actually matters > in a cluster.So the global bitmap size changes on a regular basis? I guess I thought that once you formatted the file system the size of the global bitmap would be a constant size for the life of the filesystem. (Until you added a resize capability). Is that not true? If so I guess that explains it better why I need to traverse through the file system in order to figure out the size of it. I'm just trying to make my life easier by not needing to traverse the file system. Of course I haven't gone through every function in making the EVMS plugin so I may need to anyway :( John
> So the global bitmap size changes on a regular basis?well, ocfs v1 already has the resizing capability, so no reason why v2 will not have that. Infact, with the current layout, we could even provide hot resizing.