Commit 66041f45 authored by Marc Vef's avatar Marc Vef
Browse files

PoC: more remove optimization

parent 8966818f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ constexpr typename std::underlying_type<E>::type to_underlying(E e) {

std::shared_ptr<gkfs::metadata::Metadata> get_metadata(const std::string& path, bool follow_links = false);

std::string get_metadata_no_shared(const std::string& path, bool follow_links = false);
int get_metadata_no_shared(const std::string& path, std::string& attr, bool follow_links = false);

int metadata_to_stat(const std::string& path, const gkfs::metadata::Metadata& md, struct stat& attr);

+7 −5
Original line number Diff line number Diff line
@@ -239,13 +239,14 @@ int gkfs_remove(const std::string& path) {
//    if (!md) {
//        return -1;
//    }
    auto attr = gkfs::util::get_metadata_no_shared(path);
    if (attr.empty()) {
    string attr{};
    auto err = gkfs::util::get_metadata_no_shared(path, attr);
    if (err) {
        return -1;
    }
    gkfs::metadata::Metadata md{attr};
    bool has_data = S_ISREG(md.mode()) && (md.size() != 0);
    auto err = gkfs::rpc::forward_remove(path, !has_data, md.size());
    err = gkfs::rpc::forward_remove(path, !has_data, md.size());
    if (err) {
        errno = err;
        return -1;
@@ -279,8 +280,9 @@ int gkfs_access(const std::string& path, const int mask, bool follow_links) {
 * @return 0 on success, -1 on failure
 */
int gkfs_stat(const string& path, struct stat* buf, bool follow_links) {
    auto attr = gkfs::util::get_metadata_no_shared(path, follow_links);
    if (attr.empty()) {
    string attr{};
    auto err = gkfs::util::get_metadata_no_shared(path, attr, follow_links);
    if (err) {
        return -1;
    }
    gkfs::metadata::Metadata md{attr};
+3 −4
Original line number Diff line number Diff line
@@ -186,14 +186,13 @@ std::shared_ptr<gkfs::metadata::Metadata> get_metadata(const string& path, bool
    return make_shared<gkfs::metadata::Metadata>(attr);
}

string get_metadata_no_shared(const string& path, bool follow_links) {
    std::string attr;
int get_metadata_no_shared(const string& path, string& attr, bool follow_links) {
    auto err = gkfs::rpc::forward_stat(path, attr);
    if (err) {
        errno = err;
        return ""s;
        return true;
    }
    return attr;
    return false;
}

/**