Commit f5a98c98 authored by gerd's avatar gerd

experimental: trying to merge overlapping commits


git-svn-id: https://gps.dynxs.de/private/svn/app-plasma/trunk@647 55289a75-7b90-4627-9e07-ffb4263930b2
parent db2d4cea
......@@ -24,6 +24,8 @@
(* mount -t nfs -o soft,proto=tcp,port=2801,mountport=2800,mountproto=tcp,nfsvers=3,nolock,noacl,nordirplus,sec=none 127.0.0.1:/test /mnt *)
(* TODO: limit commit speed *)
module PA = Plasma_rpcapi_aux
module NA = Nfs3_aux
module StrSet = Plasma_util.StrSet
......@@ -60,6 +62,7 @@ type rundata =
mutable ug_admin_check_t : float;
esys : Unixqueue.event_system;
wbuf : Plasma_writebuf.write_buffer;
commit_count : (int64, int) Hashtbl.t;
}
type nfs_error =
......@@ -212,6 +215,12 @@ let read_multiple = 1
let write_multiple = 16
let ignore_concurrent_commits = true
(* Enables that if several COMMIT requests arrive for the same inode
at nearly the same time, only the last COMMIT is actually done.
This is unsafe, but speeds up a lot
*)
let configure_auth cluster conf =
Plasma_client.configure_auth cluster
Pfs_auth.privileged_user
......@@ -441,6 +450,7 @@ let new_rundata conf =
ug_admin_check_t = Unix.gettimeofday();
esys = esys;
wbuf = Plasma_writebuf.create cluster wbufs 0.1;
commit_count = Hashtbl.create 5
} in
load_mount_table rd;
rd
......@@ -2282,6 +2292,32 @@ let proc_link conf sess (fh, name_in_dir) emit =
emit
let pre_commit rd inode =
let n = try Hashtbl.find rd.commit_count inode with Not_found -> 0 in
Hashtbl.replace rd.commit_count inode (n+1)
let do_commit_e full_name rd inode =
let n = try Hashtbl.find rd.commit_count inode with Not_found -> 0 in
assert(n > 0);
if n=1 || not ignore_concurrent_commits then (
dlogf "%s: actually committing (inode=%Ld)" full_name inode;
Plasma_writebuf.flush_e rd.wbuf inode
++ (fun () ->
Plasma_client.flush_e rd.cluster inode 0L 0L
)
)
else
eps_e (`Done ()) rd.esys
let post_commit rd inode =
let n = try Hashtbl.find rd.commit_count inode with Not_found -> 0 in
if n=1 then
Hashtbl.remove rd.commit_count inode
else
Hashtbl.replace rd.commit_count inode (n-1)
let proc_write conf sess (fh, offset, count, stable, data) emit =
let rd = get_rundata conf in
try
......@@ -2343,6 +2379,9 @@ let proc_write conf sess (fh, offset, count, stable, data) emit =
functions will return it
*)
let need_commit =
stable = `data_sync || stable = `file_sync in
Plasma_util.rpc_srv_reply full_name sess emit
(no_transaction_e rd full_name
(fun esys ->
......@@ -2359,18 +2398,13 @@ let proc_write conf sess (fh, offset, count, stable, data) emit =
)
else (
dlogf "%s: after_write" full_name;
match stable with
| `unstable ->
return_e count `unstable
| `data_sync | `file_sync ->
Plasma_writebuf.flush_e rd.wbuf inode
++ (fun () ->
Plasma_client.flush_e
rd.cluster inode offset (Int64.of_int count)
)
++ (fun () ->
dlogf "%s: after_flush" full_name;
return_e count `file_sync)
if need_commit then
do_commit_e full_name rd inode
++ (fun () ->
dlogf "%s: after_flush" full_name;
return_e count `file_sync)
else
return_e count `unstable
) in
Plasma_client.get_cached_inodeinfo_e rd.cluster inode false
......@@ -2382,7 +2416,12 @@ let proc_write conf sess (fh, offset, count, stable, data) emit =
that are done via NFS. Updates from other clients can be
invisible for a short period of time, though.
*)
if need_commit then pre_commit rd inode;
wr_loop_e 0
>> (fun st ->
if need_commit then post_commit rd inode;
st
)
)
)
)
......@@ -2425,15 +2464,19 @@ let proc_commit conf sess (fh, offset, count) emit =
functions will return it
*)
pre_commit rd inode;
Plasma_util.rpc_srv_reply "commit" sess emit
(no_transaction_e rd "commit"
(fun esys ->
Plasma_writebuf.flush_e rd.wbuf inode
++ (fun () -> Plasma_client.flush_e rd.cluster inode 0L 0L)
do_commit_e "commit" rd inode
++ (fun () ->
return_e ()
)
)
>> (fun st ->
post_commit rd inode; st
)
)
with
| Nfs_error e ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment