Commit 6c9df78e authored by Ramon Nou's avatar Ramon Nou
Browse files

Merge branch 'rnou/opts' into 'master'

server-side -C option


See merge request !295
parents f055adfe c3e662be
Loading
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -43,7 +43,9 @@ gkfs_getsingleserverdir_filtered(const char* path,
                                 struct dirent_extended** dirp, int server,
                                 const char* start_key, const char* filter_name,
                                 int64_t filter_size, int64_t filter_ctime,
                                 char** last_key_out, uint64_t* total_checked_out) __attribute__((weak));
                                 int count_only,
                                 char** last_key_out, uint64_t* matched_count_out,
                                 uint64_t* total_checked_out) __attribute__((weak));

/* PFIND OPTIONS EXTENDED */
typedef struct {
@@ -267,13 +269,15 @@ worker_routine(void* arg) {

                ssize_t n = -1;
                uint64_t server_checked_count = 0;
                uint64_t server_matched_count = 0;

                for(size_t i = 0; i < max_retries; ++i) {
                    n = gkfs_getsingleserverdir_filtered(
                            data->workdir->c_str(), &entries, server_id,
                            last_key ? last_key : "",
                            data->opt->name_pattern.c_str(), f_size, f_ctime,
                            &new_last_key, &server_checked_count);
                            data->opt->just_count,
                            &new_last_key, &server_matched_count, &server_checked_count);
                    if(n >= 0)
                        break;
                    // simple retry delay could be added here
@@ -296,7 +300,7 @@ worker_routine(void* arg) {

                local_checked += server_checked_count;

                if(n > 0 && entries) {
                if(n > 0 && entries && !data->opt->just_count) {
                    char* ptr = reinterpret_cast<char*>(entries);
                    int bytes_processed = 0;
                    while(bytes_processed < n) {
@@ -321,6 +325,9 @@ worker_routine(void* arg) {
                } else {
                    if(entries)
                        free(entries);
                    if (data->opt->just_count) {
                        local_found += server_matched_count;
                    }
                }

                if(last_key)
+3 −2
Original line number Diff line number Diff line
@@ -139,11 +139,12 @@ forward_read_inline(const std::string& path, void* buf, off64_t offset,
std::tuple<int,
           std::vector<std::tuple<const std::string, unsigned char, size_t,
                                  time_t>>,
           uint64_t, std::string>
           uint64_t, uint64_t, std::string>
forward_get_dirents_filtered(const std::string& path, int server,
                             const std::string& start_key,
                             const std::string& filter_name,
                             int64_t filter_size, int64_t filter_ctime);
                             int64_t filter_size, int64_t filter_ctime,
                             bool count_only = false);

} // namespace rpc
} // namespace gkfs
+5 −3
Original line number Diff line number Diff line
@@ -314,12 +314,13 @@ struct rpc_get_dirents_filtered_in_t {
    std::string filter_name;
    int64_t filter_size;
    int64_t filter_ctime;
    bool count_only;

    template <class Archive>
    void
    serialize(Archive& ar) {
        ar(path, start_key, bulk_handle, filter_name, filter_size,
           filter_ctime);
        ar(path, start_key, bulk_handle, filter_name, filter_size, filter_ctime,
           count_only);
    }
};

@@ -328,11 +329,12 @@ struct rpc_get_dirents_filtered_out_t {
    size_t dirents_size;
    uint64_t total_checked;
    std::string last_scanned_key;
    uint64_t matched_count;

    template <class Archive>
    void
    serialize(Archive& ar) {
        ar(err, dirents_size, total_checked, last_scanned_key);
        ar(err, dirents_size, total_checked, last_scanned_key, matched_count);
    }
};

+2 −2
Original line number Diff line number Diff line
@@ -210,11 +210,11 @@ public:
     */
    [[nodiscard]] std::tuple<
            std::vector<std::tuple<std::string, unsigned char, size_t, time_t>>,
            uint64_t, std::string>
            size_t, size_t, std::string>
    get_dirents_filtered(const std::string& dir, const std::string& start_key,
                         const std::string& filter_name,
                         const int64_t filter_size, const int64_t filter_ctime,
                         size_t max_entries = 0) const;
                         bool count_only = false, size_t max_entries = 0) const;

    /**
     * @brief Iterate over complete database, note ONLY used for debugging and
+5 −3
Original line number Diff line number Diff line
@@ -95,10 +95,11 @@ public:

    virtual std::tuple<
            std::vector<std::tuple<std::string, unsigned char, size_t, time_t>>,
            uint64_t, std::string>
            size_t, size_t, std::string>
    get_dirents_filtered(const std::string& dir, const std::string& start_key,
                         const std::string& filter_name,
                         const int64_t filter_size, const int64_t filter_ctime,
                         bool count_only = false,
                         size_t max_entries = 0) const = 0;

    virtual void*
@@ -186,14 +187,15 @@ public:

    std::tuple<
            std::vector<std::tuple<std::string, unsigned char, size_t, time_t>>,
            uint64_t, std::string>
            size_t, size_t, std::string>
    get_dirents_filtered(const std::string& dir, const std::string& start_key,
                         const std::string& filter_name,
                         const int64_t filter_size, const int64_t filter_ctime,
                         bool count_only = false,
                         size_t max_entries = 0) const {
        return static_cast<T const&>(*this).get_dirents_filtered_impl(
                dir, start_key, filter_name, filter_size, filter_ctime,
                max_entries);
                count_only, max_entries);
    }

    void*
Loading