Use a thread pool for inode fetches, and remove some debugging output.
[bluesky.git] / nfs3 / nfs3.c
index 061f835..7662a2c 100644 (file)
@@ -208,6 +208,8 @@ void nfsproc3_setattr_3_svc(setattr3args *argp, RPCRequest *req)
                   inode);
     result.status = NFS3_OK;
 
+    bluesky_inode_do_sync(inode);
+
     g_mutex_unlock(inode->lock);
     async_rpc_send_reply(req, &result);
 }
@@ -428,6 +430,7 @@ void nfsproc3_write_3_svc(write3args *argp, RPCRequest *req)
     result.write3res_u.resok.count = argp->count;
     result.write3res_u.resok.committed = FILE_SYNC;
 
+    bluesky_inode_do_sync(inode);
     g_mutex_unlock(inode->lock);
 
     async_rpc_send_reply(req, &result);
@@ -470,6 +473,7 @@ void nfsproc3_create_3_svc(create3args *argp, RPCRequest *req)
         return;
     }
 
+    g_mutex_lock(fs->lock);
     BlueSkyInode *file;
     file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), fs, BLUESKY_REGULAR);
     file->nlink = 1;
@@ -481,9 +485,11 @@ void nfsproc3_create_3_svc(create3args *argp, RPCRequest *req)
     file->ntime = time;
     g_mutex_lock(file->lock);
     bluesky_insert_inode(fs, file);
+    g_mutex_unlock(fs->lock);
     bluesky_directory_insert(dir, argp->where.name, file->inum);
 
     bluesky_inode_update_ctime(dir, TRUE);
+    bluesky_inode_update_ctime(file, FALSE);
 
     wcc.after.present = TRUE;
     encode_fattr3(&wcc.after.post_op_attr_u.attributes, dir);
@@ -497,6 +503,8 @@ void nfsproc3_create_3_svc(create3args *argp, RPCRequest *req)
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_len = 8;
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_val = (char *)&fh_bytes;
 
+    bluesky_inode_do_sync(file);
+    bluesky_inode_do_sync(dir);
     g_mutex_unlock(file->lock);
     g_mutex_unlock(dir->lock);
 
@@ -540,6 +548,7 @@ void nfsproc3_mkdir_3_svc(mkdir3args *argp, RPCRequest *req)
         return;
     }
 
+    g_mutex_lock(fs->lock);
     BlueSkyInode *file;
     file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), fs, BLUESKY_DIRECTORY);
     file->nlink = 1;
@@ -551,10 +560,12 @@ void nfsproc3_mkdir_3_svc(mkdir3args *argp, RPCRequest *req)
     file->ntime = time;
     g_mutex_lock(file->lock);
     bluesky_insert_inode(fs, file);
+    g_mutex_unlock(fs->lock);
     bluesky_directory_insert(dir, argp->where.name, file->inum);
     set_attributes(file, &argp->attributes);
 
     bluesky_inode_update_ctime(dir, TRUE);
+    bluesky_inode_update_ctime(file, FALSE);
 
     wcc.after.present = TRUE;
     encode_fattr3(&wcc.after.post_op_attr_u.attributes, dir);
@@ -568,6 +579,8 @@ void nfsproc3_mkdir_3_svc(mkdir3args *argp, RPCRequest *req)
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_len = 8;
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_val = (char *)&fh_bytes;
 
+    bluesky_inode_do_sync(file);
+    bluesky_inode_do_sync(dir);
     g_mutex_unlock(file->lock);
     g_mutex_unlock(dir->lock);
     async_rpc_send_reply(req, &result);
@@ -609,6 +622,7 @@ void nfsproc3_symlink_3_svc(symlink3args *argp, RPCRequest *req)
         return;
     }
 
+    g_mutex_lock(fs->lock);
     BlueSkyInode *file;
     file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), fs, BLUESKY_SYMLINK);
     file->nlink = 1;
@@ -621,9 +635,11 @@ void nfsproc3_symlink_3_svc(symlink3args *argp, RPCRequest *req)
     file->symlink_contents = g_strdup(argp->symlink.symlink_data);
     g_mutex_lock(file->lock);
     bluesky_insert_inode(fs, file);
+    g_mutex_unlock(fs->lock);
     bluesky_directory_insert(dir, argp->where.name, file->inum);
 
     bluesky_inode_update_ctime(dir, TRUE);
+    bluesky_inode_update_ctime(file, FALSE);
 
     wcc.after.present = TRUE;
     encode_fattr3(&wcc.after.post_op_attr_u.attributes, dir);
@@ -637,6 +653,8 @@ void nfsproc3_symlink_3_svc(symlink3args *argp, RPCRequest *req)
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_len = 8;
     result.diropres3_u.resok.obj.post_op_fh3_u.handle.data.data_val = (char *)&fh_bytes;
 
+    bluesky_inode_do_sync(file);
+    bluesky_inode_do_sync(dir);
     g_mutex_unlock(file->lock);
     g_mutex_unlock(dir->lock);
     async_rpc_send_reply(req, &result);
@@ -687,6 +705,7 @@ void nfsproc3_remove_3_svc(diropargs3 *argp, RPCRequest *req)
     encode_fattr3(&result.wccstat3_u.wcc.after.post_op_attr_u.attributes,
                   dir);
 
+    bluesky_inode_do_sync(dir);
     g_mutex_unlock(dir->lock);
     async_rpc_send_reply(req, &result);
 }
@@ -754,6 +773,8 @@ void nfsproc3_rmdir_3_svc(diropargs3 *argp, RPCRequest *req)
     encode_fattr3(&result.wccstat3_u.wcc.after.post_op_attr_u.attributes,
                   dir);
 
+    bluesky_inode_do_sync(dir);
+    bluesky_inode_do_sync(inode);
     g_mutex_unlock(inode->lock);
     g_mutex_unlock(dir->lock);
     async_rpc_send_reply(req, &result);
@@ -803,6 +824,9 @@ void nfsproc3_rename_3_svc(rename3args *argp, RPCRequest *req)
     else
         result.status = NFS3ERR_PERM;
 
+    bluesky_inode_do_sync(dir2);
+    bluesky_inode_do_sync(dir1);
+
     g_mutex_unlock(dir1->lock);
     if (dir1->inum != dir2->inum)
         g_mutex_unlock(dir2->lock);
@@ -877,6 +901,8 @@ void nfsproc3_link_3_svc(link3args *argp, RPCRequest *req)
     encode_fattr3(&result.link3res_u.res.file_attributes.post_op_attr_u.attributes, inode);
     result.link3res_u.res.linkdir_wcc = wcc;
 
+    bluesky_inode_do_sync(inode);
+    bluesky_inode_do_sync(dir);
     g_mutex_unlock(inode->lock);
     g_mutex_unlock(dir->lock);
     async_rpc_send_reply(req, &result);
@@ -1133,7 +1159,7 @@ void nfsproc3_commit_3_svc(commit3args *argp, RPCRequest *req)
     g_mutex_lock(inode->lock);
     encode_pre_wcc(&result.commit3res_u.resok.file_wcc, inode);
 
-    //bluesky_inode_do_sync(inode);
+    bluesky_inode_do_sync(inode);
 
     result.commit3res_u.resok.file_wcc.after.present = TRUE;
     encode_fattr3(&result.commit3res_u.resok.file_wcc.after.post_op_attr_u.attributes, inode);