From 47733e5040a551876907dc54e39da839360b0e84 Mon Sep 17 00:00:00 2001 From: ibwroot Date: Tue, 21 Feb 2017 09:54:02 +0800 Subject: [PATCH] Coding style and remove unused debug log. (#315) (#660) --- fuse_lowlevel/bfs_ll_mount.cc | 10 +++++----- src/nameserver/namespace.cc | 11 +++-------- src/sdk/bfs.h | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/fuse_lowlevel/bfs_ll_mount.cc b/fuse_lowlevel/bfs_ll_mount.cc index 6011749d..d4d3ae55 100644 --- a/fuse_lowlevel/bfs_ll_mount.cc +++ b/fuse_lowlevel/bfs_ll_mount.cc @@ -144,13 +144,13 @@ static void bfs_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) { struct dirbuf { char *p; - uint32_t size_used; + int32_t size_used; }; static void dirbuf_add(fuse_req_t req, struct dirbuf *b, const char *name, fuse_ino_t ino) { struct stat st; - size_t oldsize = b->size_used; + int32_t oldsize = b->size_used; b->size_used += fuse_add_direntry(req, NULL, 0, name, NULL, 0); b->p = (char *) realloc(b->p, b->size_used); memset(&st, 0, sizeof(st)); @@ -159,9 +159,9 @@ static void dirbuf_add(fuse_req_t req, struct dirbuf *b, const char *name, b->size_used); } -static int reply_buf_limited(fuse_req_t req, const char *buf, size_t bufsize, - off_t off, size_t maxsize) { - if (bufsize - off > 0) +static int reply_buf_limited(fuse_req_t req, const char *buf, int32_t bufsize, + off_t off, int32_t maxsize) { + if (bufsize > off) return fuse_reply_buf(req, buf + off, min(bufsize - off, maxsize)); else return fuse_reply_buf(req, NULL, 0); diff --git a/src/nameserver/namespace.cc b/src/nameserver/namespace.cc index cdbff813..63b7779a 100644 --- a/src/nameserver/namespace.cc +++ b/src/nameserver/namespace.cc @@ -243,14 +243,13 @@ bool NameSpace::IGet(int64_t entry_id, FileInfo * info) { //unfinshed, consistency not guranteed, to be continue bool NameSpace::DeleteFileInfo(const std::string file_key, NameServerLog* log) { - int64_t entry_id; std::string file_key_i; FileInfo info; if (!GetFromStore(file_key, &info)) { LOG(INFO, "DeleteFileInfo GetFromStore for entry_id return false"); return false; } - entry_id = info.entry_id(); + int64_t entry_id = info.entry_id(); LOG(DEBUG, "DeleteFileInfo get entry_id from db_ E%ld return true", entry_id); leveldb::Status s = db_->Delete(leveldb::WriteOptions(), file_key); if (!s.ok()) { @@ -315,8 +314,6 @@ StatusCode NameSpace::BuildPath(const std::string& path, FileInfo* file_info, st LOG(INFO, "path split fail %s", path.c_str()); return kBadParameter; } - LOG(INFO, "path split %s", path.c_str()); - LOG(INFO, "path[0] %s", paths[0].c_str()); /// Find parent directory, create if not exist. int64_t parent_id = kRootEntryid; @@ -770,14 +767,12 @@ StatusCode NameSpace::InternalDeleteDirectory(const FileInfo& dir_info, leveldb::Status s = db_->Write(leveldb::WriteOptions(), &batch); if (!s.ok()) { - LOG(INFO, "Unlink dentry fail: %s\n", dir_info.name().c_str()); - LOG(FATAL, "Namespace write to db_ fail!"); + LOG(FATAL, "Unlink dentry write to db_ fail: %s\n", dir_info.name().c_str()); return kUpdateError; } s = db_i->Write(leveldb::WriteOptions(), &batch); if (!s.ok()) { - LOG(INFO, "Unlink dentry fail: %s\n", dir_info.name().c_str()); - LOG(FATAL, "Namespace write to db_i fail!"); + LOG(FATAL, "Unlink dentry write to db_i fail: %s\n", dir_info.name().c_str()); return kUpdateError; } LOG(INFO, "Delete directory done: %s[%s]", diff --git a/src/sdk/bfs.h b/src/sdk/bfs.h index fc3c6a54..e1f9fed6 100644 --- a/src/sdk/bfs.h +++ b/src/sdk/bfs.h @@ -78,7 +78,7 @@ class File { }; struct BfsFileInfo { - uint64_t ino; + int64_t ino; int64_t size; uint32_t ctime; uint32_t mode;