Skip to contentSkip to conversation

cifs: local caching support using FS-Cache

PATCH In review Suresh Jayaraman 8 participants 14 messages Jul 5, 2010 – Jul 30, 2010 8 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover cifs: local caching support using FS-Cache

This patchset is a second try at adding persistent, local caching facility for CIFS using the FS-Cache interface.

The cache index hierarchy which is mainly used to locate a file object or discard a certain subset of the files cached, currently has three levels:
- Server
- Share
- File

The server index object is keyed by IPaddress of the server, socket family and the port. The superblock index object is keyed by the sharename and the inode object is keyed by the UniqueId. The cache coherency is ensured by checking the LastWriteTime, LastChangeTime and end of file (eof) reported by the server.

Changes since last post:
-------------------------
- fix a bug during registration with FS-Cache
- fix a bug while storing pages to the cache. The earlier set needed an rsize of 4096 to make caching working properly due to this bug.
- server index key uses {IPaddress,family,port} tuple instead of servername
- root dir of the share is validated by UniqueId/IndexNumber. Almost all servers seem to provide one of them and it's unique.
- we now check LastWriteTime, LastChangeTime and eof of server for data coherency. CreateTime could be considered once some of related development effort advances
- dropped the patch to guard cifsglob.h against multiple inclusion as it has been included in Jeff Layton's tree
- some cleanups

To try these patches:

- apply this patchset in order
- mount the share, for e.g. mount -t cifs //server/share -o user=guest
- try copying a huge file (say few hundred MBs) from mount point to local filesystem (during the first time, the cache will be initialized)
- when you copy the second time, it should be read from the local cache (you could unmount and remount to reduce the page cache impact).

Known issues
--------------
- when the 'noserverino' mount option is used, the client generates UniqueId itself rather than using the UniqueId from the server. As we use UniqueId to ensure that the root directory did not change under the hood, we won't be able to benefit from the cache.
- the cache coherency check may not be reliable always as some CIFS servers are known not to update mtime until the filehandle is closed.

Suresh Jayaraman (09):
cifs: add kernel config option for CIFS Client caching support
cifs: register CIFS for caching
cifs: define server-level cache index objects and register them with FS-Cache
cifs: define superblock-level cache index objects and register them
cifs: define inode-level cache object and register them
cifs: FS-Cache page management
cifs: store pages into local cache
cifs: read pages from FS-Cache
cifs: add mount option to enable local caching

 Kconfig      |    9 +
 Makefile     |    2 
 cache.c      |  331 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 cifs_fs_sb.h |    1 
 cifsfs.c     |   15 ++
 cifsglob.h   |   10 +
 connect.c    |   16 ++
 file.c       |   50 ++++++++
 fscache.c    |  236 ++++++++++++++++++++++++++++++++++++++++++
 fscache.h    |  136 ++++++++++++++++++++++++
 inode.c      |    7 +
 11 files changed, 813 insertions(+)

A message that is not in the archive (sent off-list or not yet received): 1278333663-30464-1-git-send-email-sjayaraman-l3A5Bk7waGM@public.gmane.org

#2 lore raw
Quoted 4 lines · Suresh Jayaraman

This patchset is a second try at adding persistent, local caching facility for CIFS using the FS-Cache interface.

Just wondering, have you bench marked this at all? I'd be interested to see how this compares (performance and scaling) to an oplock-centric design.

I'd hazard a guess that with pipelining support in SMB2 the performance will be even better since you can have a hot cache and more requests in flight.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Scott Lovenberg
Quoted 6 lines · Suresh Jayaraman

This patchset is a second try at adding persistent, local caching facility for
CIFS using the FS-Cache interface.

Quoted 5 lines

Just wondering, have you bench marked this at all?  I'd be interested to see how this compares (performance and scaling) to an oplock-centric design.

I'd hazard a guess that with pipelining support in SMB2 the performance will be even better since you can have a hot cache and more requests in flight.

Yes - very plausibly

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTin2tKtkWTflrrzBMYBEd6SFr35uYUl1SmfYlj9W-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 10 lines · Steve French
Quoted 8 lines · Scott Lovenberg
Quoted 6 lines · Suresh Jayaraman

This patchset is a second try at adding persistent, local caching facility for
CIFS using the FS-Cache interface.

Quoted 3 lines
Quoted 3 lines

Just wondering, have you bench marked this at all? �I'd be interested to see how this compares (performance and scaling) to an oplock-centric design.

Yes, I have done a few performance benchmarks with the cifs client (and not SMB2) and I'll post them early nextweek when I'm back (as I'm travelling now).

However, I have never done scalability tests (not sure whether there is a way to simulate a number of cifs clients).

Quoted 5 lines
Quoted 2 lines

I'd hazard a guess that with pipelining support in SMB2 the performance will be even better since you can have a hot cache and more requests in flight.

Yes - very plausibly

I have not tried the new SMB2 client. But, it seems the pipelining support, Oplocks (only Level II kind) could help improve performance.

Thanks,

Signature · 1 line
Suresh Jayaraman

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 11 lines · Suresh Jayaraman
Quoted 10 lines · Steve French
Quoted 8 lines · Scott Lovenberg
Quoted 6 lines · Suresh Jayaraman

This patchset is a second try at adding persistent, local caching facility for
CIFS using the FS-Cache interface.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Just wondering, have you bench marked this at all? �I'd be interested to see how this compares (performance and scaling) to an oplock-centric design.

Yes, I have done a few performance benchmarks with the cifs client (and not SMB2) and I'll post them early nextweek when I'm back (as I'm travelling now).

Here are some results from my benchmarking:

Environment
------------

I'm using my T60p laptop as the CIFS server (running Samba) and one of my test machines as CIFS client, connected over an ethernet of reported speed 1000 Mb/s. The TCP bandwidth as seen by a pair of netcats between the client and the server is about 786.24 Mb/s.

Client has a 2.8 GHz Pentium D CPU with 2GB RAM Server has a 2.33GHz Core2 CPU (T7600) with 2GB RAM

Test
-----
The benchmark involves pulling a 200 MB file over CIFS to the client using cat to /dev/zero under `time'. The wall clock time reported was recorded.

Note
----
- The client was rebooted after each test, but the server was not.
- The entire file was loaded into RAM on the server before each test to eliminate disk I/O latencies on that end.
- A seperate partition of size 4GB has been dedicated for the cache.
- There were no other CIFS client that was accessing the Server when the tests were performed.

First, the test was run on the server twice and the second result was recorded (noted as Server below).

Secondly, the client was rebooted and the test was run with cachefiled not running and was recorded (noted as None below).

Next, the client was rebooted, the cache contents (if any) were erased with mkfs.ext3 and test was run again with cachefilesd running (noted as COLD)

Next the client was rebooted, tests were run with cachefilesd running this time with a populated cache (noted as HOT).

Finally, the test was run again without unmounting, stopping cachefiled or rebooting to ensure pagecache is valid (noted as PGCACHE).

The benchmark was repeated twice:

Cache (state) Run #1 Run#2
============= ======= =======
Server 0.107 s 0.090 s
None 6.497 s 6.440 s
COLD 6.707 s 6.635 s
HOT 5.286 s 5.078 s
PGCACHE 0.090 s 0.091 s

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected. (I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

Thanks,

Signature · 1 line
Suresh Jayaraman

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

ethtool?

David

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 6 lines · On Thu, 22 Jul 2010 18:40:00 +0100 David Howells…
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

Quoted 7 lines

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

ethtool?

There's also the "netem" thingy that allows you to add arbitrary latencies to packets (for simulating long-haul network links).

Signature · 1 line
Jeff Layton <[email protected]>
#13 lore raw
In reply to a message not in the archive
Quoted 9 lines · David Howells
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

More interesting than a slow network is testing with more clients. 10 clients should be able to get 10x the read performance from the client-local cache, probably more than the server's peak disk/network bandwidth.

Cheers, Andreas

#14 lore raw

In my opinion there should be article published about this, describing fs-cache generally, and these kinds of benchmarks!

Using fs-cache for network filesystem is an important issue, and should get "exposure".

Stef Bon

2010/7/23 Andreas Dilger <[email protected]>:

Quoted 19 lines · David Howells
Quoted 9 lines
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

More interesting than a slow network is testing with more clients.  10 clients should be able to get 10x the read performance from the client-local cache, probably more than the server's peak disk/network bandwidth.

Cheers, Andreas

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): AANLkTikF5Oz5pobaPUJebUg+yPuoVy_B5PBz+nuUTSii-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#16 lore raw
Quoted 2 lines · Stef Bon

In my opinion there should be article published about this, describing fs-cache generally, and these kinds of benchmarks!

FS-Cache is nicely documented on Documentation/filesystems/caching/fscache.txt present in the kernel source. IIRC, LWN - http://lwn.net/ had published a couple of articles about FS-Cache. I agree that there is little information available about the use-cases and benchmarks.

What do you mean exactly by article? More blog entries or article in magazines or whitepaper sort? Which one do you think has a good chance of reaching the target audience?

Thanks,

Quoted 19 lines

Using fs-cache for network filesystem is an important issue, and should get "exposure".

Stef Bon

2010/7/23 Andreas Dilger <[email protected]>:

Quoted 13 lines · David Howells
Quoted 9 lines
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

More interesting than a slow network is testing with more clients. 10 clients should be able to get 10x the read performance from the client-local cache, probably more than the server's peak disk/network bandwidth.

Signature · 1 line
Suresh Jayaraman
#17 lore raw

2010/7/23 Suresh Jayaraman <[email protected]>:

Quoted 10 lines · Stef Bon
Quoted 2 lines

In my opinion there should be article published about this, describing fs-cache generally, and these kinds of benchmarks!

FS-Cache is nicely documented on Documentation/filesystems/caching/fscache.txt present in the kernel source. IIRC, LWN - http://lwn.net/ had published a couple of articles about FS-Cache. I agree that there is little information available about the use-cases and benchmarks.

Quoted 4 lines

What do you mean exactly by article? More blog entries or article in magazines or whitepaper sort? Which one do you think has a good chance of reaching the target audience?

Well,

I do not have an answer right now, I guess articles in general magazines, not exactly the Linux Community,
but ICT in general.

What strikes me most, is that there are a lot of people, you, me, probably everyone reading this, are working on a lot of projects, creating excellent software, making the Linux better and better.

But does it get exposure? Is the public aware of what happens with Linux, does "they" know Linux or at least heard of?
No! That's a pity.
Everybody knows the iPad, why not Linux?

Linux needs better marketing!!

Stef Bon

#18 lore raw
In reply to a message not in the archive
Quoted 6 lines · David Howells
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

Quoted 7 lines

That's what I see with NFS and AFS too.

Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

ethtool?

Thanks for the pointer. Here are the results on a 100Mb/s network:

Environment
------------

I'm using my T60p laptop as the CIFS server (running Samba) and one of my test machines as CIFS client, connected over an ethernet of reported speed 1000 Mb/s. ethtool was used to throttle the speed to 100 Mb/s. The TCP bandwidth as seen by a pair of netcats between the client and the server is about 89.555 Mb/s.

Client has a 2.8 GHz Pentium D CPU with 2GB RAM Server has a 2.33GHz Core2 CPU (T7600) with 2GB RAM

Test
-----
The benchmark involves pulling a 200 MB file over CIFS to the client using cat to /dev/zero under `time'. The wall clock time reported was recorded.

Note
----
- The client was rebooted after each test, but the server was not.
- The entire file was loaded into RAM on the server before each test to eliminate disk I/O latencies on that end.
- A seperate partition of size 4GB has been dedicated for the cache.
- There were no other CIFS client that was accessing the Server when the tests were performed.

First, the test was run on the server twice and the second result was recorded (noted as Server below).

Secondly, the client was rebooted and the test was run with cachefiled not running and was recorded (noted as None below).

Next, the client was rebooted, the cache contents (if any) were erased with mkfs.ext3 and test was run again with cachefilesd running (noted as COLD)

Next the client was rebooted, tests were run with cachefilesd running this time with a populated disk cache (noted as HOT).

Finally, the test was run again without unmounting, stopping cachefiled or rebooting to ensure pagecache is valid (noted as PGCACHE).

The benchmark was repeated twice:

Cache (state) Run #1 Run#2
============= ======= =======
Server 0.104 s 0.107 s
None 26.042 s 26.576 s
COLD 26.703 s 26.787 s
HOT 5.115 s 5.147 s
PGCACHE 0.091 s 0.092 s

I think the results are inline with the expectations given the speed reported by netcat.

As noted by Andreas, the read performance with more number of clients would be more interesting as the cache can positively impact the scalability. However, I don't have a number of clients or know a way to simulate a large number of cifs clients. The cache also can positively impact the performance on heavily loaded network and/or server due to reduction of network calls to the server.

Also, it should be noted that local caching is not for all workloads and a few workloads could suffer (for e.g. read-once type workloads).

Thanks,

Signature · 1 line
Suresh Jayaraman

A message that is not in the archive (sent off-list or not yet received): [email protected]

#20 lore raw
Quoted 9 lines · Suresh Jayaraman
Quoted 8 lines · David Howells
Quoted 3 lines · Suresh Jayaraman

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected.

That's what I see with NFS and AFS too.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

(I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

ethtool?

Thanks for the pointer. Here are the results on a 100Mb/s network:

<snip>
Excellent data - thx

Quoted 4 lines

As noted by Andreas, the read performance with more number of clients would be more interesting as the cache can positively impact the scalability. However, I don't have a number of clients or know a way to simulate a large number of cifs clients.

You could simulate increased load by running multiple smbtorture instances from each real client, and perhaps some local dbench like activity run locally on the server.

Quoted 3 lines

The cache also can positively
impact the performance on heavily loaded network and/or server due to reduction of network calls to the server.

Reminds me a little about the discussions during the last few SMB2 plugfests:

http://channel9.msdn.com/posts/Darryl/Peer-Content-Branch-Caching-and-Retrieval-Presentation/

and an earlier one (I couldn't find the newer version of this talk)
http://channel9.msdn.com/pdc2008/ES23/

and

Signature · 3 lines
Thanks,

Steve
#21 lore raw
In reply to a message not in the archive
Quoted 56 lines · Suresh Jayaraman

Here are some results from my benchmarking:

Environment
------------

I'm using my T60p laptop as the CIFS server (running Samba) and one of my test machines as CIFS client, connected over an ethernet of reported speed 1000 Mb/s. The TCP bandwidth as seen by a pair of netcats between the client and the server is about 786.24 Mb/s.

Client has a 2.8 GHz Pentium D CPU with 2GB RAM Server has a 2.33GHz Core2 CPU (T7600) with 2GB RAM

Test
-----
The benchmark involves pulling a 200 MB file over CIFS to the client using cat to /dev/zero under `time'. The wall clock time reported was recorded.

Note
----
- The client was rebooted after each test, but the server was not.
- The entire file was loaded into RAM on the server before each test to eliminate disk I/O latencies on that end.
- A seperate partition of size 4GB has been dedicated for the cache.
- There were no other CIFS client that was accessing the Server when the tests were performed.

First, the test was run on the server twice and the second result was recorded (noted as Server below).

Secondly, the client was rebooted and the test was run with cachefiled not running and was recorded (noted as None below).

Next, the client was rebooted, the cache contents (if any) were erased with mkfs.ext3 and test was run again with cachefilesd running (noted as COLD)

Next the client was rebooted, tests were run with cachefilesd running this time with a populated cache (noted as HOT).

Finally, the test was run again without unmounting, stopping cachefiled or rebooting to ensure pagecache is valid (noted as PGCACHE).

The benchmark was repeated twice:

Cache (state) Run #1 Run#2
============= ======= =======
Server 0.107 s 0.090 s
None 6.497 s 6.440 s
COLD 6.707 s 6.635 s
HOT 5.286 s 5.078 s
PGCACHE 0.090 s 0.091 s

Quoted 11 lines

As it can been seen, the performance while reading when data is cache hot (disk) is not great as the network link is a Gigabit ethernet (with server having working set in memory) which is mostly expected. (I could not get access to a slower network (say 100 Mb/s) where the real performance boost could be evident).

Thanks,

Suresh, thanks for taking the time to run these bench marks. :)