DEVELOPMENT
As for previous patches,
most interesting happens when reading in ext2_readpage() and when
writing in ext2_writepage() and ext2_file_write(). In fact,
in 2.2 kernel, compression occures on cluster of blocks. So when reading
or writing a part of a file, we first have to compute the cluster on which
I/O occures, then we have to get every buffers of the cluster, uncompress
the data if needed, then reading/writing happens "as for normal files".
In 2.4 kernels, I/O occures through page cache: i.e. when reading/writing
to part of the file, first the corresponding page is get, we then
get the needed buffers, which point to the page; this means that for keeping
same work as for 2.2, we have to use the notion of cluster of page. For
getting every buffers of a cluster, we first get every pages of the cluster,
then get buffers of every pages...
So, things happens as
follow :
-
ext2_readpage :
If data corresponding to the page are
in a compressed cluster, this functions perfoms more works: instead of
reading one page, it reads the whole "cluster of pages". In fact, anyway,
we have to read all compressed buffer. Once we have got all buffers of
the cluster, uncompressed (at least a part of) the data, and located the
part of the uncompressed data which correspond to the requested page, there
is not any more lot of work for also reading (i.e. doing some memcpy) other
pages belonging to this cluster. So, the first reading of the first page
of the cluster is quite longer, but then, every pages of the cluster are
uptodate in the cache.
-
ext2_writepage :
An overhead has been added for pages belonging
to a compressed cluster. In fact, if cluster is still compressed on the
disk, we can't directly write the page (which contains uncompressed data)
in the middle of a compressed cluster. So, we first have to uncompress
the whole cluster on the disk, then we can write the new data of the dirty
page(s).
-
ext2_file_write :
This replaces generic_file_write()
when e2compress option is activated. It is a copy of generic_file_write().
The main difference is that instead of looping page by page, we loops on
cluster of page.
In each loop :
-
We compute the cluster on which beginning
of data (to be written) belongs to.
-
Then, we get all pages of the cluster.
-
If cluster is a compressed one, we read
all pages, and uncompress it. Otherwise, we perfoms a prepare_write(),
as
in generic_file_write().
-
We copy the data on each page from user
space,
-
Call commit_write() on dirty
pages.
-
When reaching end of cluster, we compress
it. (As in 2.2)
Note : Another implentation could have
been to keep
generic_file_write(), and add an overhead to ext2_prepare_write()
and ext2_commit_write(), on the first access to a page of a compressed
cluster, whole cluster will be uncompressed (i.e. all pages of the cluster
will be read and uncompressed in ext2_prepare_write) and when commiting
the last page of the cluster, compression occures...
-
Other places in ext2 :
Other changes occures as in 2.2 for managing
the compression flags of files and specific `COMPRESSED_BLK_ADDR' address
for compressed blocks. So please, refer to existing documentation for 2.2
about this topic (http://www.netspace.net.au/~reiter/e2compr/index.html
).
Back to main
Last modification :Mon Jun 3 14:18:33 MEST
2002