diff options
author | Simon Rettberg | 2018-07-05 13:23:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-05 13:23:24 +0200 |
commit | 43cc60130cbf419d5bbf0c26e74da573fda94aab (patch) | |
tree | 04169feabb08cd274c5a4aeae12252de6b183ce4 /src/server/uplink.c | |
parent | [SERVER] Always use fsync instead of fdatasync (diff) | |
download | dnbd3-43cc60130cbf419d5bbf0c26e74da573fda94aab.tar.gz dnbd3-43cc60130cbf419d5bbf0c26e74da573fda94aab.tar.xz dnbd3-43cc60130cbf419d5bbf0c26e74da573fda94aab.zip |
[SERVER] Don't keep bg replication blocks in fs cache
Further improving cache handling, don't keep blocks
in cache that have been requested via background replication.
It's likely these aren't needed in the near future.
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r-- | src/server/uplink.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c index 26e5d4e..2bd6ed2 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -555,7 +555,7 @@ static void uplink_sendRequests(dnbd3_connection_t *link, bool newOnly) */ static void uplink_sendReplicationRequest(dnbd3_connection_t *link) { - if ( !_backgroundReplication ) return; // Don't do background replication + if ( !_backgroundReplication || link->cacheFd == -1 ) return; // Don't do background replication if ( link == NULL || link->fd == -1 ) return; dnbd3_image_t * const image = link->image; if ( image->realFilesize < DNBD3_BLOCK_SIZE ) return; @@ -738,6 +738,10 @@ static void uplink_handleReceive(dnbd3_connection_t *link) if ( start == link->replicationHandle ) { // Was our background replication link->replicationHandle = 0; + // Try to remove from fs cache if no client was interested in this data + if ( !served && link->cacheFd != -1 ) { + posix_fadvise( link->cacheFd, start, inReply.size, POSIX_FADV_DONTNEED ); + } } else { // Was some client -- reset idle counter link->idleCount = 0; |