Changeset 8174

Show
Ignore:
Timestamp:
12/09/09 15:00:28 (3 years ago)
Author:
pcarns
Message:

Patch from Bart Taylor to clear stranded bstreams at server start time.
This finishes any background deletions that were not completed before the
previous daemon was stopped.

Location:
trunk/src/io/trove/trove-dbpf
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/io/trove/trove-dbpf/dbpf-mgmt.c

    r7958 r8174  
    18591859    coll_p->meta_sync_enabled = 1; /* MUST be 1 !*/ 
    18601860 
    1861  
    18621861    dbpf_collection_register(coll_p); 
    18631862    *out_coll_id_p = coll_p->coll_id; 
     1863 
     1864    clear_stranded_bstreams(coll_p->coll_id); 
     1865 
    18641866    return 1; 
    18651867} 
  • trunk/src/io/trove/trove-dbpf/dbpf-open-cache.c

    r8110 r8174  
    2323#include <string.h> 
    2424#include <db.h> 
     25#include <dirent.h> 
    2526 
    2627#include "trove.h" 
     
    634635} 
    635636 
     637void clear_stranded_bstreams(TROVE_coll_id coll_id) 
     638{ 
     639    char path_name[PATH_MAX]; 
     640    DIR *current_dir = NULL; 
     641    struct dirent *current_dirent = NULL; 
     642    struct stat file_info; 
     643    struct file_struct *tmp_item; 
     644 
     645    DBPF_GET_STRANDED_BSTREAM_DIRNAME(path_name, PATH_MAX, 
     646                                      my_storage_p->name, coll_id); 
     647 
     648    /* remove entries in the stranded bstreams directory */ 
     649    current_dir = opendir(path_name); 
     650    if(current_dir) 
     651    { 
     652        while((current_dirent = readdir(current_dir))) 
     653        { 
     654            if((strcmp(current_dirent->d_name, ".") == 0) || 
     655               (strcmp(current_dirent->d_name, "..") == 0)) 
     656            { 
     657                continue; 
     658            } 
     659            tmp_item = (struct file_struct *) malloc(sizeof(struct file_struct)); 
     660            if(!tmp_item) 
     661            { 
     662                gossip_err("Unable to allocate memory for file_struct [%d].\n", errno); 
     663                return; 
     664            } 
     665            tmp_item->pathname = malloc(PATH_MAX); 
     666            if(!tmp_item->pathname) 
     667            { 
     668                gossip_err("Unable to allocate memory for pathname[%d].\n", errno); 
     669                free(tmp_item); 
     670                return; 
     671            } 
     672            snprintf(tmp_item->pathname, PATH_MAX, "%s/%s", path_name, 
     673                     current_dirent->d_name); 
     674            if(stat(tmp_item->pathname, &file_info) < 0) 
     675            { 
     676                gossip_err("error doing stat on bstream entry\n"); 
     677                continue; 
     678            } 
     679            assert(S_ISREG(file_info.st_mode)); 
     680            /* Add to the queue */ 
     681 
     682            pthread_mutex_lock(&dbpf_unlink_context.mutex); 
     683            qlist_add_tail(&tmp_item->list_link, &dbpf_unlink_context.global_list); 
     684            pthread_cond_signal(&dbpf_unlink_context.data_available); 
     685            pthread_mutex_unlock(&dbpf_unlink_context.mutex); 
     686            gossip_debug(GOSSIP_DBPF_OPEN_CACHE_DEBUG, 
     687              "Added [%s] to the queue.\n", tmp_item->pathname); 
     688        } 
     689        closedir(current_dir); 
     690    } 
     691    else 
     692    {    
     693        gossip_err("Unable to open standed bstream directory [%s] to " 
     694          "perform initialization stranded bstream cleanup", path_name); 
     695    } 
     696} 
     697 
    636698/* 
    637699 * Local variables: 
  • trunk/src/io/trove/trove-dbpf/dbpf-open-cache.h

    r7560 r8174  
    4545    TROVE_handle handle); 
    4646 
     47void clear_stranded_bstreams(TROVE_coll_id coll_id); 
     48     
    4749#endif /* __DBPF_OPEN_CACHE_H__ */ 
    4850