From: alebre <al...@us...> - 2010-07-16 17:58:00
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "kdfs". The branch, make_kdfs_compile has been updated via 0a5fafb4d704c3289c4098cd1f0630a73ad763bf (commit) via ba273f9d120a368e9695820f4a5ec870733c81e4 (commit) via 3bbbed7a4f4e8a8b1004f461a5f0ba04ab12be9e (commit) via 090f74bf5431caa5d6a8185de22341ec77eafc5e (commit) via 8b0bb79523c616e2aa8fd416f79cb73565010619 (commit) via 3b8fb32c231e5f80316411e2bb13f5360f49b6c6 (commit) via 5c596a74126b55d39d13d692df8a24ce1c3dd036 (commit) via e15f87760a1dccc6c616ade8bb2f421869e4482d (commit) via 9383856e21bc97dbfb77238eb74191ab0547ece0 (commit) via 9113791a3242de6969a7f67296c7f8fae3ef26f7 (commit) via 16b4cb4ebff0d9a88d6d7dbb2a3ecee89fa68c48 (commit) via 2d39f2f748e1eea9336b7145575b9d125339beac (commit) via 0f2e8ee95482b45bb8ac00b83b0bd4c6dc057d9b (commit) via 5dff30da37d4a3025802574679d0ba8407d1a2c1 (commit) via c229cdad8e5fe9bd57a49fe6148b291fef354f91 (commit) via c1d31811d9e4b1358230542f67458ee87ec5547b (commit) via 8c7474f07d53cc2468aee4f8f5dc095960ac6fe6 (commit) via c3c276eeb89104372f379225d2ffad63c43301c1 (commit) via f005d8966ce2d525c3fa2aa8e59c25b4eb05271e (commit) via f1eec05cb5d153ca139c9071d8fd7489dbc500fe (commit) via cdc1332343c70b215f485c029a6e75d5c0442cd9 (commit) via 4193891fb73aa4543d6db50bf960b53c1c780dbd (commit) via 4df2c21c5af6595909dc24f9d28c09c1dee842c2 (commit) via a270cd2ca7216f8ca5a6227c0cdd4fb908582146 (commit) via f041999d4dc815719b22495e0656457991f96928 (commit) via 9da633cb78e774b493b1ec4cc4fb31e9c8ca1a68 (commit) via 674937a9434df52deb13edfa6051430d5bf4c067 (commit) via 32588b71ad2ee3ae8826c60ea4b91a36019fa72b (commit) via 7b8a6c6a8a542f97a13f1c5c0018cf5457d02c70 (commit) via beb6b202b243e76386f8853d784c4e8e166de6b2 (commit) via e757e2229a2ee28687e87dba352a2f475f45f39d (commit) via e3930cbdc732d9340f648b07fa4294955bf0c685 (commit) via bd19c359594fd42e376f0d6f03dd246c79903bd9 (commit) via c1bf78d3d880bbba980b029b7367294934ff8fb2 (commit) via c6e8959712da37c7a89382fdecb164f4351e5574 (commit) via f40bc6b2ec214e684b1ac6b616c0504b3fe3e409 (commit) via f5f70e81c1ffae2b4c8839f326e20041a9016842 (commit) via c3cc4a43ef75bb6d23de18726c6edc40d3c7f230 (commit) via 219fc8ed624a922e3c92ebeeace31c7576bab42d (commit) via 2f092f4723372a44a9e4eb6eb6e109bd2b35438d (commit) via 7b5fbb42c65ee3c568f678732f8d9dc8fce61488 (commit) via a40da323cee09a81248f39f13d9c147323fab698 (commit) via ef8926360c63835a5de166fd19459667cd466ac6 (commit) via 218ee6af320ff06a219aed78d5ded00b346649f3 (commit) via 0c5796cd12341f34f432bf7c591db534836d1678 (commit) via 44db85eabdab32970f594977ea67691d6bc7b81b (commit) via e5c85337231900ab685094a473e82262ebad8822 (commit) via 6a7b45bf5e2563d2bbb3292b051cb7bc330266f9 (commit) via 172f87e793f2fd8113aba2737d2398e2c6ec2606 (commit) via 3ebf1fe76829048c780b50ea97a3e3681be7edcf (commit) via 0c33cbb63453a214e6765045e6c65acfb370971f (commit) via 93509461baa098a86f437c529b8d51eb899a9cb1 (commit) via 9edb056255f3b1f6e9679921103c938c6dd92b38 (commit) via 7bf2b7a3da2d6c06da3fbb59815ff54984f21b34 (commit) via b93c8d0a68d718b47c8d4b6087ca29f60186cd1a (commit) via d9b2ed8089a8cb29b47e6b045f261c11f01ea83f (commit) via 5aefddd62d71d816d73d52ad5cab812bd883cfe1 (commit) via 99661928dfd3d98f3dfbe1c6da14e9c43a399e66 (commit) via 52e8c8c8ac043e6bc72600c53520d5768b0d5838 (commit) via 6fef4a7d75ddb477f4a14aed2dfdc67ec667f608 (commit) via 2600a0a96c451049a4f565c5bf0d12d09099ef4e (commit) via a799f46fd811889edb53d5d979198322b5bfedfd (commit) via 6fd70409dfe3cfebc73fe9d8c132accdb761733d (commit) via b9383e5a4c18ac45d353aedf3885e9076ae2a08e (commit) via a81c21cf4d379a0ad00fd6e45aa365204734b948 (commit) via 360e45920da5d9091b0ad01d0870b77a5e84ec2f (commit) via a257353c0dd31dcfc58625010629933ce9a28556 (commit) via 4d7e232a957aa9d3cfb101edda7f9305ae6e6523 (commit) via 935c1efa04d725d406381c6bee88987c1ba5f298 (commit) via 420e630822240878afa0a8e42ad8c5c32f54b95a (commit) via 3ae242096a4ba25912707ac1f8ea195d43dd31f5 (commit) via aadc28a44a96d150c029879dff9e7c4d2b9d367e (commit) via 0593ba2fd498f108752d838c8845fa345abf132a (commit) via 7e6bdd1980ff369bd80930078a78ffa5c72258b3 (commit) via 9d4fe024182089b94a75e6a69ec404d29c6d2767 (commit) via b6621ca22cc6f7ff554d9ada81be85d136ee2a15 (commit) via 67001dd033f11cd794b699280d3a0cb82eebc893 (commit) via dc4ec7bcf3acbca9928025c7046d2e9a492f3d7e (commit) via 92c06b7e5e2cdfb260de29a203907103a3fd37b8 (commit) via 99b45125e6bfc2d759c4697a659b383f31c174a9 (commit) via fb2330856d0d1a3b436d9b3720014cd566433bcc (commit) via f1b6d7667ab7d3c85cc4537a9e952bea9fe5d4db (commit) via 252dcef418bae5e0855cc9012ddef72d6c5789bc (commit) via 0a797ad01da3fb016c920f61ceb2e50707594544 (commit) via 74afd5c76e54cefe0ad43ec1741a2ec703ec09e6 (commit) via c4db295659806df93e3739da508a53bd532e0c14 (commit) via c1d19dd7597d639d4c7768e1d48e4996c6ba7f72 (commit) via 69428ccc9f34330c9c3b35880336ea768c02d40b (commit) via d1ebe2dc902e01eb3776d4fc5a828327ed5d40e0 (commit) via 535a3ef59a5c6437bfaadfcf3691bf5b28da342b (commit) via 024219c54516b95e6797fcf291617a673f9f0dd5 (commit) via ddd6d62c99a23e3e5117a78e210b37242cd63ef4 (commit) via fb0a6ba846f4d769d71626f1a65854bef8dac9d4 (commit) via 9b5794a95d509fca027241a7e6ec7cccf73d991e (commit) via 37658e4e5c973f0e9850b696f888f567fb3ddb55 (commit) via b55dcc81a6024b08103b79cf8dc28356c5d9f910 (commit) via c4b2150c60ae55707cd2a473f551ee91f5c9a6cd (commit) via bc946ddf67a666bb98c7c0528d2fa9f3c7c5969b (commit) via 1b21814c4b646bfbb641e9fd405e4f272c7c7cd6 (commit) via 17c5d9e21fab9da5bce79947f9c17904c0b00ad3 (commit) via cf6706cb1d42bbd310e61345809ad091e6f62625 (commit) via e96a1902e77e81871355ebdfe9cd50e2894bc9e0 (commit) via b510be9352a7352a3e7a3775c64c98360092a4eb (commit) via f3983a31250908da9fcaff19aefa441a0a5660e1 (commit) via f0279e67f5440e6618096263a91889873ef6d0dd (commit) via ccb13eefef23a2de98f2f11169a90f5755920649 (commit) via aba92d2f1caad1ab2b5fed3fdf44ceca108cb932 (commit) via 9ee7e890fa9441451a5cf3f4b197b4bd8c4a2714 (commit) via ae83789f49803335d0e3b6942323d2b513f6557c (commit) via fc347c00bf4cc802b2690fb922061d206669c32c (commit) via 32da93685380eb387e69b20272acc37d5b15b0b9 (commit) via 59d25b545cec7c7cf66d1f9b59d488b223528119 (commit) via b3744b82edc36d4ee96c59fb50a7794dcb085d86 (commit) via 27c7ec4e77b3f66c7f9dc8fb8466164de34daa47 (commit) via da35ecf6f2523e43ba6b952d3564251b14da5139 (commit) via 08c279f543021658b698cce23945a18098eb2dc4 (commit) via 32c8b04b90a1346ab7f523cc1886b61da6ceceff (commit) via 00d49c44015e00ee7d2b42cda0049d0339630211 (commit) via 7a119509759dde9535a83a086b22bb0afd7a578b (commit) via 01eae2e9693e8767c3817993c1412e1bb54660f2 (commit) via 9013771e0b8bf3737b3d3680973b84734b68c6ef (commit) via dbfb34b0725ec62529e98a003fd2aeec2c463130 (commit) via 5cee4cd6ee4d566341833aba20e5c57f61b0eaa0 (commit) via 4dd5098c1271af15103ed0f4c4139f58ca92069e (commit) via 7977df55623f4d13c9e5a3773a7084e3075681d3 (commit) via f105a1fb13b132bb3220fe73f31b661db8a5c48a (commit) via c78b6c7cc44d0e9430d867650fcc4e462d4e0e54 (commit) via 6218efcd52b4c1aa952dec73fe49b71e45372b5a (commit) via 4198f62c2e9e1c7ffc2ad493fa57dfb2ebc4c2ae (commit) via 736df693434ca837fd7bfb19acfcc00d202775e4 (commit) from 09fd7d0746ec22a4e163188aebb7147fb8c61322 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0a5fafb4d704c3289c4098cd1f0630a73ad763bf Author: ad <leb...@fr...> Date: Fri Jul 16 08:27:12 2010 +0000 Add dynamic debug into kDFS diff --git a/fs/kdfs/README b/fs/kdfs/README index 1a20771..9c7272b 100644 --- a/fs/kdfs/README +++ b/fs/kdfs/README @@ -139,6 +139,12 @@ struct kdfs_dir_entry { SUPERBLOCK MANAGEMENT: - - - - - - - - - - - - - - - - +A first KDDM set is used to manage each superblock clusterwide. Besides, kDFS +exploits a particular KDFS superblock that is in charge of maintaining which +nodes take part to the physical storage space. It consists of a simple bitmap. +This particular superblock is stored into the superblock KDDM set +(KDFS_SB_KDDM_ID) at the KDFS_CWSB_ID position (cf. super.h). + INODE MANAGEMENT: - - - - - - - - - - - - - - - - diff --git a/fs/kdfs/TODO b/fs/kdfs/TODO index 4aa4eaa..2c57e69 100644 --- a/fs/kdfs/TODO +++ b/fs/kdfs/TODO @@ -40,6 +40,7 @@ Prio. added added Type What 2 pierre 080227 bugfix check about obj_entry->lock (spinlock) being locked in kddm_io_invalidate_object when calling kdfs_iol_inode_invalidate_object (which calls a sleeping function) +2 adrien 100717 Bugfix check why we locally destroy the content kddm set the inode is dropped by the VFS (cfs. super.c kdfs_drop_inode) DONE ~~~~ diff --git a/fs/kdfs/address_space.c b/fs/kdfs/address_space.c index b7516c8..99331b6 100644 --- a/fs/kdfs/address_space.c +++ b/fs/kdfs/address_space.c @@ -79,6 +79,7 @@ int kdfs_readpage(struct file *file, struct page *page) struct kdfs_page *k_page = NULL; struct kdfs_inode *k_inode = NULL; + PRINT_FUNCTION_NAME; ASSERT(page != NULL); k_inode=kdfs_ilocalfind(page->mapping->host->i_ino); @@ -622,15 +623,16 @@ int kdfs_iol_page_first_touch(kddm_obj_t *objEntry, /* The page can be already in the cache, especially when we dynamically change the default owner */ k_page->page = find_get_page(k_mapping, pageid); if (!k_page->page) { - DEBUG(DBG_TRACE, "Can't find page for file/directory = %ld and " \ - "page id = %ld, So created and locked\n", iolinker_data->ino, - pageid); k_page->page = find_or_create_page(k_mapping, pageid, (mapping_gfp_mask(k_mapping)|__GFP_ZERO) & ~__GFP_FS); k_page->flags = K_PG_locked; page_addr = (char *) kmap(k_page->page); pos = (loff_t)pageid * PAGE_SIZE; + DEBUG(DBG_TRACE, "Can't find page for file/directory = %ld and " \ + "page id = %ld, So created and locked (kmap page address %p, page address %p)\n", iolinker_data->ino, + pageid,page_addr, k_page->page); + /* The page should be filled only if it was not handled * by another node before (i.e if the page is already in * the cache, it means that the page has been inserted @@ -939,11 +941,13 @@ int content_instantiate(kddm_set_t *kddm_set, void *private_data, int master) /* Retrieve local path corresponding to kfds inode number*/ kdfs_getphysicalpath(k_sb, content_data->ino, content_data->phys_dirname); - if (check_create_phys_dir(content_data->phys_dirname, 0777, 0, 0) != 0) - BUG(); + result = check_create_phys_dir(content_data->phys_dirname, 0777, 0, 0); + if (result != 0) + DEBUG(DBG_PANIC, "Something wrong during check_create_phys_dir (error=%d)", result); /* Try to open the physical associated file */ phys_dirname = content_data->phys_dirname + strlen(content_data->phys_dirname); + // For versionning purpose: TODO add specific defines snprintf(content_data->phys_dirname, PATH_MAX, "%s/.meta.index", content_data->phys_dirname); filp = open_phys_file(content_data->phys_dirname, O_RDONLY, 0644, 0, 0); *phys_dirname = '\0'; @@ -975,15 +979,14 @@ int content_instantiate(kddm_set_t *kddm_set, void *private_data, int master) /* TODO PRIORITY 2, Adrien, we could have some issue if the kernel tries to remove the inode during this code */ /* Retrieve the local ref to the k_mapping object */ - inode = ilookup(k_sb->sb, content_data->ino); if (inode) { DEBUG(DBG_INFO, "K_mapping from the cache\n"); content_data->k_mapping = inode->i_mapping; iput(inode); } else if (inode_linked_node(content_data->ino) == kerrighed_node_id){ - DEBUG(DBG_INFO, "K_mapping will be retrieve from iget\n"); - inode = kdfs_getinode(k_sb->sb, content_data->ino); + DEBUG(DBG_PANIC, "K_mapping will be retrieve from iget, however this should not occur\n"); +// inode = kdfs_getinode(k_sb->sb, content_data->ino); content_data->k_mapping = inode->i_mapping; } else { /* do dummy stuff */ diff --git a/fs/kdfs/debug_kdfs.h b/fs/kdfs/debug_kdfs.h index d3859ca..abe9ac0 100644 --- a/fs/kdfs/debug_kdfs.h +++ b/fs/kdfs/debug_kdfs.h @@ -1,13 +1,14 @@ /* * KDDM File System file - debug macros * - * @file debug_kdfs.h + * @file debug_kdfs.h * - * @author Adrien Lebre + * @author Adrien Lebre * - * @maintainer Adrien Lebre + * @maintainer Adrien Lebre * - * Copyright (C) 2006-2007, XtreemOS Consortium. + * Copyright (C) 2006-2007, XtreemOS Consortium. + * Copyright (C) 2008-20xx, Mines Nantes - INRIA Rennes Bretagne Atlantique - LINA . */ #ifndef __KDFS_DEBUG__ @@ -28,8 +29,11 @@ #define DBG_WARNING 2 #define DBG_TRACE 3 #define DBG_INFO 4 +#define DBG_DBG 5 -#define KDFS_DEBUG_LEVEL 2 +#define KDFS_DEBUG_LEVEL 4 + +#define KDFS_GENERALINFO "%s & %d | " #ifdef DEBUG #undef DEBUG @@ -38,12 +42,10 @@ #ifdef NDEBUG # define DEBUG(level, format, args...) do {} while(0) #else -# define DEBUG(level, format, args...) \ +# define DEBUG(level, format, ...) \ do { \ if (KDFS_DEBUG_LEVEL >= level) { \ - /*pr_debug*/printk("KDFS - %s @ (%s : %d) - %d | ", __func__, __FILE__, __LINE__, \ - current->pid) ; \ - /*pr_debug*/printk(format, ## args) ; \ + pr_debug("%s @ %d | " format, __func__, __LINE__, ##__VA_ARGS__) ; \ } \ if(level == DBG_PANIC)\ BUG();\ diff --git a/fs/kdfs/file.c b/fs/kdfs/file.c index 70de1ec..367c23c 100644 --- a/fs/kdfs/file.c +++ b/fs/kdfs/file.c @@ -61,7 +61,7 @@ ssize_t kdfs_read(struct file *filp, char *buf, size_t count, loff_t *ppos) struct kdfs_inode *kdfs_inode = NULL; DEBUG(DBG_INFO, - "read %zd bytes from file %s at offset %lld in buffer %p\n", + "Start to read %zd bytes from file %s at offset %lld in buffer %p\n", count, filp->f_dentry->d_name.name, *ppos, buf); kdfs_inode = kdfs_iget(filp->f_dentry->d_inode->i_ino); @@ -263,7 +263,7 @@ kerrighed_node_t kdfs_iol_file_default_owner (kddm_set_t *kddm_set, // check who's the default owner of the object !!! ret_val = page_linked_node(objid); - DEBUG(DBG_INFO, "######### /\\/\\/\\/ page owner ::: %d\n", ret_val); + DEBUG(DBG_DBG, "######### /\\/\\/\\/ page owner ::: %d\n", ret_val); return ret_val; } diff --git a/fs/kdfs/inode.c b/fs/kdfs/inode.c index 2e238a3..d6536d5 100644 --- a/fs/kdfs/inode.c +++ b/fs/kdfs/inode.c @@ -8,7 +8,8 @@ * * @maintainer Adrien Lebre * - * Copyright (C) 2006-2007, XtreemOS Consortium. + * Copyright (C) 2006-2007, XtreemOS Consortium. + * Copyright (C) 2008-20xx, Mines Nantes - INRIA Rennes Bretagne Atlantique - LINA . */ #include <net/krgrpc/rpc.h> @@ -65,7 +66,7 @@ void print_dentry_cont(struct dentry *entry, int print_inode_info) /*****************************************************************************/ /* */ -/* INODE INTERNAL FUNCTIONS */ +/* INODE INTERNAL FUNCTIONS */ /* */ /*****************************************************************************/ @@ -785,15 +786,16 @@ int kdfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { - // TODO Which funtions set up the right inode; - // TODO Why this function is called twice when i make a ls struct inode *inode = dentry->d_inode; struct kdfs_inode *k_inode; struct kdfs_cw_sb *k_cwsb; int r = 0; DEBUG (DBG_TRACE, "getattr for file %s (inodeid=%ld)\n", dentry->d_name.name,inode->i_ino); - k_cwsb = __kdfs_grab_cwsb(); + + // Check whether the node storing the .meta file is reachable or not + // TODO: Adrien, performance impact ? + k_cwsb = __kdfs_get_cwsb(); if (!test_bit(inode_linked_node(inode->i_ino), (unsigned long *) k_cwsb->cw_bitmap->map)) { r = -ENODEV; __kdfs_put_cwsb(); @@ -801,6 +803,7 @@ int kdfs_getattr(struct vfsmount *mnt, } __kdfs_put_cwsb(); + // Get the atttr for the inode k_inode = kdfs_iget(inode->i_ino); //k_inode->inode->i_blocks = k_inode->inode->i_size / (k_inode->inode->i_blkbits/8); //TODO Find a way to determine n for 2^n = (k_inode->inode->i_blkbits/8) @@ -1129,13 +1132,16 @@ int kdfs_iol_inode_first_touch(kddm_obj_t *objEntry, "First touch inode (%ld;%ld)\n", kddm_set->id, objid); - if (objEntry->object == NULL) { k_inode = kmalloc(sizeof(struct kdfs_inode), GFP_KERNEL); ASSERT(k_inode != NULL); atomic_set(&k_inode->cw_count, 0); /* initialise the extents */ kdfs_file_extent_init(k_inode); - + + /* + * Initialize and fill the k_inode + */ + // Case 1: it's a new file, so a new inode if (flags & KDDM_CREATE_ON_FT) { k_inode->inode = new_inode (k_sb->sb); k_inode->flags = K_INODE_CREATING|K_INODE_INITIALIZING; @@ -1143,37 +1149,28 @@ int kdfs_iol_inode_first_touch(kddm_obj_t *objEntry, DEBUG(DBG_PANIC, "Cannot find inode %ld\n", objid); k_inode->inode->i_ino = objid; insert_inode_hash(k_inode->inode); - } else { - /* - * Check if the inode is locally in the cache - * Can happen when a content associated kddm set has been instantiated - */ - k_inode->inode = ilookup(k_sb->sb, objid); - if (k_inode->inode) { - iput(k_inode->inode); - } else { - k_inode->inode = kdfs_getinode(k_sb->sb, objid); - kdfs_file_extent_read_from_file(k_inode); - } - k_inode->flags = K_INODE_OK; + } + // Case 2: the inode already exists, so fill it from the HDD + else if (kdfs_fill_kinode(k_sb->sb, objid, k_inode) < 0) { + DEBUG(DBG_PANIC, "Cannot retrieve the physical informations to fill the k_inode"); } + k_inode->flags = K_INODE_OK; k_inode->content_setid = KDDM_SET_UNUSED; objEntry->object = (void *) k_inode; DEBUG(DBG_INFO, "inode count %d\n", atomic_read(&k_inode->inode->i_count)); - } - if (inode_linked_node(objid) == kerrighed_node_id) { - char *phys_dirname; - /* Find the physical path corresponding to the KDFS inode */ - phys_dirname = kmalloc(PATH_MAX, GFP_KERNEL); - ASSERT(phys_dirname != NULL); - - kdfs_getphysicalpath(k_sb, objid, phys_dirname); - if (check_create_phys_dir(phys_dirname, 0777, 0, 0) != 0) - BUG(); - kfree(phys_dirname); - } +// if (inode_linked_node(objid) == kerrighed_node_id) { +// char *phys_dirname; +// /* Find the physical path corresponding to the KDFS inode */ +// phys_dirname = kmalloc(PATH_MAX, GFP_KERNEL); +// ASSERT(phys_dirname != NULL); +// +// kdfs_getphysicalpath(k_sb, objid, phys_dirname); +// if (check_create_phys_dir(phys_dirname, 0777, 0, 0) != 0) +// BUG(); +// kfree(phys_dirname); +// __kdfs_twice_putsb(k_sb); PRINT_FUNCTION_EXIT; diff --git a/fs/kdfs/physical_fs.c b/fs/kdfs/physical_fs.c index 2c9637b..8bd60c1 100644 --- a/fs/kdfs/physical_fs.c +++ b/fs/kdfs/physical_fs.c @@ -102,6 +102,8 @@ long create_phys_dir(const char *pathname, path_put(&nd.path); out: + if (error != 0) + DEBUG(DBG_ALERT, "function EXIT: Physical operation does not succeed (error %d)\n",error); __revert_old_creds(overridden_creds, old_creds); return error; diff --git a/fs/kdfs/super.c b/fs/kdfs/super.c index b2fc70e..d91e522 100644 --- a/fs/kdfs/super.c +++ b/fs/kdfs/super.c @@ -262,6 +262,12 @@ ino_t kdfs_get_freeino(struct kdfs_super_block *k_sb) DEBUG(DBG_INFO, "Next free inode #: %lu\n", sb_bitmap_get_available(k_sb)); + /* Force bitmap synchronization for each inode creation + * PERFORMANCE IMPACT ! + * TODO Priority 3: Adrien, Find the right place to synchronize the bitmap on HDD + */ + sb_bitmap_save(k_sb); + ino = full_inode_number(ino, k_sb->sb_nodeid); out: PRINT_FUNCTION_EXIT; @@ -393,7 +399,7 @@ void kdfs_getphysicalpath(struct kdfs_super_block *k_sb, unsigned long ino, tmp_nodeid = inode_linked_node(ino); sprintf(phys_filename, "%s%d/%ld-%ld/%ld", k_sb->k_opt->part_name, tmp_nodeid, (unsigned long)(tmp_ino / 100) * 100, (unsigned long)(tmp_ino / 100) * 100 + 99, tmp_ino); - DEBUG(DBG_INFO, "Physical file for inode %ld: %s\n", ino, phys_filename); + DEBUG(DBG_INFO, "function EXIT: Physical file for inode %ld: %s\n", ino, phys_filename); } /* @@ -917,20 +923,23 @@ int kdfs_statfs(struct dentry *dfs, struct kstatfs *buf) /* * Read a physical inode of kDFS - * This function is called by the VFS when a kDFS inode has to be physically + * This function is called when a kDFS inode has to be physically * read. * * @author Adrien Lebre - * @param inode the VFS inode + * @param k_inode the k_inode to fill * */ -struct inode *kdfs_getinode(struct super_block *sb, unsigned long ino) +int kdfs_fill_kinode(struct super_block *sb, unsigned long ino, struct kdfs_inode *k_inode) { struct inode *inode = NULL; struct file *file = NULL; char *phys_filename = NULL; struct kdfs_physical_inode phys_inode; - + size_t no_extents = 0, index; + struct kdfs_file_extent_info record; + struct kdfs_file_extent *new_extent, *curr; + PRINT_FUNCTION_NAME ; /* @@ -940,11 +949,19 @@ struct inode *kdfs_getinode(struct super_block *sb, unsigned long ino) * reach it. It is probably not the best and cleanest solution. */ inode = iget_locked(sb, ino); - if (!inode) - return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) - return inode; - + if (!inode){ + DEBUG(DBG_ALERT, "End of Memory, cannot allocate a new inode"); + return -ENOMEM; + } + /* + * Check if the inode is locally in the cache + * Should not occur (theoretically :/) + */ + if (!(inode->i_state & I_NEW)){ + DEBUG(DBG_ALERT, "Inode already in the cache, strange...."); + k_inode->inode=inode; + } + /* Retrieve the inode meta file */ phys_filename = kmalloc(PATH_MAX, GFP_KERNEL); ASSERT(phys_filename != NULL); @@ -974,18 +991,44 @@ struct inode *kdfs_getinode(struct super_block *sb, unsigned long ino) * kdfs_iol_inode_insert() due to the clusterwide constraints * (cf. inode.c) */ + + k_inode-> inode = inode ; + + /* + * Read the extent part + * copy/paste from kdfs_file_extent_read_from_file(struct kdfs_inode *k_inode) + * cf. file_extent.c + */ + /* read the number of elements */ + kdfs_phys_read(file, (char *)&(no_extents), sizeof(size_t), &file->f_pos); + /* now, read the extents list */ + for(index = 0; index < no_extents; index++) { + kdfs_phys_read(file, (char *)&(record), sizeof(struct kdfs_file_extent_info), &file->f_pos); + new_extent = kmalloc(sizeof(struct kdfs_file_extent), GFP_KERNEL); + new_extent->data.page_first = record.page_first; + new_extent->data.page_last = record.page_last; + new_extent->data.extent_owner = record.extent_owner; + list_add_tail(&new_extent->list_item, &k_inode->extents_list); + } + DEBUG(DBG_INFO, "\t inode extents\n"); + if (!list_empty(&k_inode->extents_list)) { + list_for_each_entry(curr, &k_inode->extents_list, list_item) { + DEBUG(DBG_INFO, "\t\t f=%lu, l=%lu, o=%d\n", curr->data.page_first, curr->data.page_last, curr->data.extent_owner); + } + } close_phys_file(file); - } else + } + else DEBUG(DBG_ALERT, - "Can't access to the KDFS inode %ld\n" - "Please verify type of the partition %s, it should be a KDFS one", - inode->i_ino, ((struct kdfs_super_block*)inode->i_sb->s_fs_info)->k_opt->part_name); + "Can't access to the KDFS inode %ld\n" + "Please verify type of the partition %s, it should be a KDFS one", + inode->i_ino, ((struct kdfs_super_block*)inode->i_sb->s_fs_info)->k_opt->part_name); kfree(phys_filename); unlock_new_inode(inode); PRINT_FUNCTION_EXIT; - return inode; + return 0; } /* @@ -1070,7 +1113,7 @@ int __kdfs_write_inode(struct kdfs_inode *k_inode) void kdfs_drop_inode(struct inode *inode) { struct kdfs_inode *k_inode = NULL; - DEBUG(DBG_INFO, "inode id %ld ", inode->i_ino); + DEBUG(DBG_INFO, "inode id %ld\n", inode->i_ino); if (inode->i_nlink) { /* Generic forget is unfortunately not exported */ @@ -1082,7 +1125,8 @@ void kdfs_drop_inode(struct inode *inode) k_inode = kdfs_igrab(inode->i_ino); /* Associated kddm desallocation */ - __local_destroy_content_kddm_set(k_inode); + // ICI + //__local_destroy_content_kddm_set(k_inode); kdfs_idrop(inode->i_ino); } else diff --git a/fs/kdfs/super.h b/fs/kdfs/super.h index fb32ada..58d2166 100644 --- a/fs/kdfs/super.h +++ b/fs/kdfs/super.h @@ -194,7 +194,7 @@ void cleanup_kdfs(void); void kdfs_getphysicalpath(struct kdfs_super_block *k_sb, unsigned long ino, char *physical_filename); int __kdfs_write_inode(struct kdfs_inode *k_inode); -struct inode *kdfs_getinode(struct super_block *sb, unsigned long ino); +int kdfs_fill_kinode(struct super_block *sb, unsigned long ino, struct kdfs_inode *k_inode); /* Get a free inode id from kdfs_sb partition */ ino_t kdfs_get_freeino(struct kdfs_super_block *k_sb); diff --git a/fs/kdfs/wip/junk-code b/fs/kdfs/wip/junk-code new file mode 100644 index 0000000..0da29e7 --- /dev/null +++ b/fs/kdfs/wip/junk-code @@ -0,0 +1,14 @@ +#ifdef NDEBUG +# define DEBUG(type, level, format, args...) do {} while(0) +#else +# define DEBUG(type, level, format, args...) \ +do { \ + if (match_debug("kDFS", type, level)) { \ + printk ("%s - (%s) - %d : ", KDFS_PART, __PRETTY_FUNCTION__, \ + current->pid) ; \ + printk (format, ## args) ; \ + } \ + if(level == DBG_PANIC)\ + BUG();\ +} while (0) +#endif commit ba273f9d120a368e9695820f4a5ec870733c81e4 Merge: 09fd7d0 3bbbed7 Author: root <root@krgserver.dirty.world> Date: Tue Jul 6 15:01:14 2010 +0000 Merge branch 'master' of git://mirrors.git.kernel.org/cluster/kerrighed/kernel into make_kdfs_compile commit 3bbbed7a4f4e8a8b1004f461a5f0ba04ab12be9e Author: Matthieu Fertré <mat...@ke...> Date: Fri Jun 25 16:44:39 2010 +0200 [BUGFIX] Fix function get_file_size() Using directly i_size_read() to get the size is unsafe on some file systems. diff --git a/fs/stat.c b/fs/stat.c index daa2e31..2311a02 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -58,20 +58,33 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) EXPORT_SYMBOL(vfs_getattr); +#ifdef CONFIG_KRG_DVFS +int do_fstat(struct file *f, struct kstat *stat) +{ + int error; + +#ifdef CONFIG_KRG_FAF + if (f->f_flags & O_FAF_CLT) + error = krg_faf_fstat(f, stat); + else +#endif + error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat); + + return error; +} +#endif + int vfs_fstat(unsigned int fd, struct kstat *stat) { struct file *f = fget(fd); int error = -EBADF; if (f) { -#ifdef CONFIG_KRG_FAF - if (f->f_flags & O_FAF_CLT) { - error = krg_faf_fstat(f, stat); - fput(f); - return error; - } -#endif +#ifdef CONFIG_KRG_DVFS + error = do_fstat(f, stat); +#else error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat); +#endif fput(f); } return error; diff --git a/include/linux/fs.h b/include/linux/fs.h index c1d3ac1..070c311 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2318,6 +2318,9 @@ void inode_set_bytes(struct inode *inode, loff_t bytes); extern int vfs_readdir(struct file *, filldir_t, void *); +#ifdef CONFIG_KRG_DVFS +extern int do_fstat(struct file *file, struct kstat *stat); +#endif extern int vfs_stat(char __user *, struct kstat *); extern int vfs_lstat(char __user *, struct kstat *); extern int vfs_fstat(unsigned int, struct kstat *); diff --git a/kerrighed/fs/mobility.c b/kerrighed/fs/mobility.c index 6e8c626..a639937 100644 --- a/kerrighed/fs/mobility.c +++ b/kerrighed/fs/mobility.c @@ -179,21 +179,14 @@ err: static int get_file_size(struct file *file, loff_t *size) { int r = 0; + struct kstat stat; -#ifdef CONFIG_KRG_FAF - if (file->f_flags & O_FAF_CLT) { - struct kstat stat; - r = krg_faf_fstat(file, &stat); - if (r) - goto exit; + r = do_fstat(file, &stat); + if (r) + goto exit; - *size = stat.size; - } else -#endif - *size = i_size_read(file->f_dentry->d_inode); -#ifdef CONFIG_KRG_FAF + *size = stat.size; exit: -#endif return r; } commit 090f74bf5431caa5d6a8185de22341ec77eafc5e Author: Matthieu Fertré <mat...@ke...> Date: Thu Jun 24 16:28:21 2010 +0200 [BUGFIX] Reset content of app_struct->restart at the end of restart Else app_struct->checkpoint may contain invalid values since app_struct->checkpoint and app_struct->restart are in the same anonymous union. diff --git a/kerrighed/epm/application/app_restart.c b/kerrighed/epm/application/app_restart.c index 1a84a82..b7ef0ec 100644 --- a/kerrighed/epm/application/app_restart.c +++ b/kerrighed/epm/application/app_restart.c @@ -1169,6 +1169,8 @@ static void handle_do_restart(struct rpc_desc *desc, void *_msg, size_t size) } #endif + memset(&app->restart, 0, sizeof(app->restart)); + err_end_pid: if (app->cred) { app->cred = NULL; commit 8b0bb79523c616e2aa8fd416f79cb73565010619 Author: Matthieu Fertré <mat...@ke...> Date: Wed Jun 23 15:50:54 2010 +0200 [BUGFIX] Fix behavior of get/setpriority() in Linux root container The original behavior has been broken by commit 3ebf1fe76829048c780b50ea97a3e3681be7edcf that implements correct behavior in Kerrighed container. diff --git a/kernel/sys.c b/kernel/sys.c index 843eea2..8367e6a 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -277,11 +277,8 @@ static int krg_setpriority_pg_user(int which, int who, int niceval) kerrighed_node_t node; int retval = -ESRCH, noderet, err; - if (!current->nsproxy->krg_ns) - goto out; - - if (!is_krg_pid_ns_root(task_active_pid_ns(current))) - goto out; + BUG_ON(!current->nsproxy->krg_ns + || !is_krg_pid_ns_root(task_active_pid_ns(current))); if (which == PRIO_PGRP && !(who & GLOBAL_PID_MASK)) @@ -365,19 +362,28 @@ SYSCALL_DEFINE3(setpriority, int, which, int, _who, int, niceval) int retval; int who = _who; + if (which == PRIO_PGRP && !who) + who = pid_nr_ns(task_pgrp(current), + task_active_pid_ns(current)); + + if (!current->nsproxy->krg_ns + || !is_krg_pid_ns_root(task_active_pid_ns(current))) { + /* not in the kerrighed container */ + retval = do_setpriority(which, who, niceval, + task_active_pid_ns(current)); + goto out; + } + switch (which) { case PRIO_PROCESS: + /* make a first try locally */ retval = do_setpriority(which, who, niceval, task_active_pid_ns(current)); if (retval == -ESRCH) retval = krg_setpriority_process(who, niceval); break; case PRIO_PGRP: - if (!who) - who = pid_nr_ns(task_pgrp(current), - task_active_pid_ns(current)); - /* do not break here */ case PRIO_USER: retval = krg_setpriority_pg_user(which, who, niceval); break; @@ -386,6 +392,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, _who, int, niceval) break; } +out: return retval; } #endif @@ -514,11 +521,8 @@ static int krg_getpriority_pg_user(int which, int who) kerrighed_node_t node; int retval = -ESRCH, noderet, err; - if (!current->nsproxy->krg_ns) - goto out; - - if (!is_krg_pid_ns_root(task_active_pid_ns(current))) - goto out; + BUG_ON(!current->nsproxy->krg_ns + || !is_krg_pid_ns_root(task_active_pid_ns(current))); if (which == PRIO_PGRP && !(who & GLOBAL_PID_MASK)) @@ -602,19 +606,29 @@ SYSCALL_DEFINE2(getpriority, int, which, int, _who) int retval; int who = _who; + if (which == PRIO_PGRP && !who) + who = pid_nr_ns(task_pgrp(current), + task_active_pid_ns(current)); + + if (!current->nsproxy->krg_ns + || !is_krg_pid_ns_root(task_active_pid_ns(current))) { + /* not in the kerrighed container */ + retval = do_getpriority(which, who, + task_active_pid_ns(current)); + goto out; + } + switch (which) { case PRIO_PROCESS: + /* make a first try locally */ retval = do_getpriority(which, who, task_active_pid_ns(current)); + if (retval == -ESRCH) retval = krg_getpriority_process(who); break; case PRIO_PGRP: - if (!who) - who = pid_nr_ns(task_pgrp(current), - task_active_pid_ns(current)); - /* do not break here */ case PRIO_USER: retval = krg_getpriority_pg_user(which, who); break; @@ -623,6 +637,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, _who) break; } +out: return retval; } #endif commit 3b8fb32c231e5f80316411e2bb13f5360f49b6c6 Author: Matthieu Fertré <mat...@ke...> Date: Tue Jun 22 14:32:04 2010 +0200 krgfaf: fix read/write stats with sendfile() diff --git a/fs/read_write.c b/fs/read_write.c index 39751cd..ffa10f4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -859,6 +859,9 @@ ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, loff_t pos; ssize_t retval; int fput_needed_in, fput_needed_out, fl; +#ifdef CONFIG_KRG_FAF + u64 rchar, wchar, syscr, syscw; +#endif /* * Get input file, and verify that it is ok.. @@ -926,10 +929,21 @@ faf_sendfile: if (in_file->f_flags & O_FAF_CLT || out_file->f_flags & O_FAF_CLT) { + rchar = get_rchar(current); + wchar = get_wchar(current); + syscr = get_syscr(current); + syscw = get_syscw(current); + if (!max) max = *ppos + count; retval = krg_faf_sendfile(out_file, in_file, ppos, count, max); + + set_rchar(current, rchar); + set_wchar(current, wchar); + set_syscr(current, syscr); + set_syscw(current, syscw); + goto update_stat; } #endif diff --git a/include/linux/sched.h b/include/linux/sched.h index 4c6669b..a76055f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2459,6 +2459,50 @@ static inline void inc_syscw(struct task_struct *tsk) { tsk->ioac.syscw++; } + +#ifdef CONFIG_KRG_FAF +static inline u64 get_rchar(struct task_struct *tsk) +{ + return tsk->ioac.rchar; +} + +static inline void set_rchar(struct task_struct *tsk, u64 rchar) +{ + tsk->ioac.rchar = rchar; +} + +static inline u64 get_wchar(struct task_struct *tsk) +{ + return tsk->ioac.wchar; +} + +static inline void set_wchar(struct task_struct *tsk, u64 wchar) +{ + tsk->ioac.wchar = wchar; +} + +static inline u64 get_syscr(struct task_struct *tsk) +{ + return tsk->ioac.syscr; +} + +static inline void set_syscr(struct task_struct *tsk, u64 syscr) +{ + tsk->ioac.syscr = syscr; +} + +static inline u64 get_syscw(struct task_struct *tsk) +{ + return tsk->ioac.syscw; +} + +static inline void set_syscw(struct task_struct *tsk, u64 syscw) +{ + tsk->ioac.syscw = syscw; +} + +#endif + #else static inline void add_rchar(struct task_struct *tsk, ssize_t amt) { @@ -2475,6 +2519,45 @@ static inline void inc_syscr(struct task_struct *tsk) static inline void inc_syscw(struct task_struct *tsk) { } + +#ifdef CONFIG_KRG_FAF +static inline u64 get_rchar(struct task_struct *tsk) +{ + return 0; +} + +static inline void set_rchar(struct task_struct *tsk, u64 rchar) +{ +} + +static inline u64 get_wchar(struct task_struct *tsk) +{ + return 0; +} + +static inline void set_rchar(struct task_struct *tsk, u64 rchar) +{ +} + +static inline u64 get_syscr(struct task_struct *tsk) +{ + return 0; +} + +static inline void set_syscr(struct task_struct *tsk, u64 syscr) +{ +} + +static inline u64 get_syscw(struct task_struct *tsk) +{ + return 0; +} + +static inline void set_syscw(struct task_struct *tsk, u64 syscw) +{ +} +#endif + #endif #ifndef TASK_SIZE_OF commit 5c596a74126b55d39d13d692df8a24ce1c3dd036 Author: Matthieu Fertré <mat...@ke...> Date: Tue Jun 22 13:49:18 2010 +0200 krgfaf: optimize sendfile if both fds are hosted on the same faf server diff --git a/fs/read_write.c b/fs/read_write.c index 72e4775..39751cd 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -848,7 +848,10 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec, return ret; } -static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, +#ifndef CONFIG_KRG_FAF +static +#endif +ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, loff_t max) { struct file * in_file, * out_file; diff --git a/include/net/krgrpc/rpcid.h b/include/net/krgrpc/rpcid.h index 22dab52..834e657 100644 --- a/include/net/krgrpc/rpcid.h +++ b/include/net/krgrpc/rpcid.h @@ -39,6 +39,7 @@ enum rpcid { RPC_FAF_GETSOCKOPT, RPC_FAF_SENDMSG, RPC_FAF_RECVMSG, + RPC_FAF_SENDFILE, RPC_FAF_NOTIFY_CLOSE, /* Ctnr Object Server Types */ diff --git a/kerrighed/fs/faf/faf_hooks.c b/kerrighed/fs/faf/faf_hooks.c index f6af126..b622ff9 100644 --- a/kerrighed/fs/faf/faf_hooks.c +++ b/kerrighed/fs/faf/faf_hooks.c @@ -1514,6 +1514,49 @@ cancel: goto out_end; } +static ssize_t fwd_sendfile(faf_client_data_t *out, faf_client_data_t *in, + loff_t *ppos, size_t count, loff_t max) +{ + struct rpc_desc *desc; + struct faf_sendfile_msg msg; + ssize_t retval; + int err; + + desc = rpc_begin(RPC_FAF_SENDFILE, in->server_id); + if (!desc) { + retval = -ENOMEM; + goto out; + } + + msg.out_fd = out->server_fd; + msg.in_fd = in->server_fd; + msg.ppos = *ppos; + msg.count = count; + msg.max = max; + + err = rpc_pack_type(desc, msg); + if (err) + goto cancel; + + err = rpc_unpack_type(desc, *ppos); + if (err) + goto cancel; + + err = rpc_unpack_type(desc, retval); + if (err) + goto cancel; + +out_end: + rpc_end(desc, 0); +out: + return retval; + +cancel: + rpc_cancel(desc); + retval = err; + goto out_end; +} + ssize_t krg_faf_sendfile(struct file *out, struct file *in, loff_t *ppos, size_t count, loff_t max) { @@ -1536,10 +1579,9 @@ ssize_t krg_faf_sendfile(struct file *out, struct file *in, loff_t *ppos, BUG_ON(!out_data && !in_data); - /* TODO: simply forward the call */ -/* if (in_data && out_data */ -/* && in_data->server_id && out_data->server_id) */ -/* return 0; */ + if (in_data && out_data + && in_data->server_id == out_data->server_id) + return fwd_sendfile(out_data, in_data, ppos, count, max); len = count; if (count > PAGE_SIZE) diff --git a/kerrighed/fs/faf/faf_server.c b/kerrighed/fs/faf/faf_server.c index 9bd8720..16f3898 100644 --- a/kerrighed/fs/faf/faf_server.c +++ b/kerrighed/fs/faf/faf_server.c @@ -1574,6 +1574,29 @@ cancel: goto out_free; } +static void handle_faf_sendfile(struct rpc_desc *desc, void *_msg, size_t size) +{ + struct faf_sendfile_msg *msg = _msg; + ssize_t retval; + int err; + + retval = do_sendfile(msg->out_fd, msg->in_fd, &msg->ppos, msg->count, + msg->max); + + err = rpc_pack_type(desc, msg->ppos); + if (err) + goto cancel; + + err = rpc_pack_type(desc, retval); + if (err) + goto cancel; + + return; + +cancel: + rpc_cancel(desc); +} + int handle_faf_notify_close (struct rpc_desc* desc, void *msgIn, size_t size) { @@ -1630,6 +1653,7 @@ void faf_server_init (void) rpc_register_void(RPC_FAF_GETSOCKOPT, handle_faf_getsockopt, 0); rpc_register_void(RPC_FAF_SENDMSG, handle_faf_sendmsg, 0); rpc_register_void(RPC_FAF_RECVMSG, handle_faf_recvmsg, 0); + rpc_register_void(RPC_FAF_SENDFILE, handle_faf_sendfile, 0); rpc_register_int(RPC_FAF_NOTIFY_CLOSE, handle_faf_notify_close, 0); } diff --git a/kerrighed/fs/faf/faf_server.h b/kerrighed/fs/faf/faf_server.h index e4ad454..66a28a2 100644 --- a/kerrighed/fs/faf/faf_server.h +++ b/kerrighed/fs/faf/faf_server.h @@ -118,6 +118,14 @@ struct faf_sendmsg_msg { size_t total_len; }; +struct faf_sendfile_msg { + int out_fd; + int in_fd; + loff_t ppos; + size_t count; + loff_t max; +}; + struct faf_poll_wait_msg { int server_fd; unsigned long objid; @@ -136,6 +144,8 @@ struct linux_dirent64; extern int do_getdents64(struct file *file, struct linux_dirent64 *dirent, unsigned int count); +extern ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, + size_t count, loff_t max); /*--------------------------------------------------------------------------* * * commit e15f87760a1dccc6c616ade8bb2f421869e4482d Author: Matthieu Fertré <mat...@ke...> Date: Tue Jun 22 13:24:20 2010 +0200 krgfaf: implements support of sendfile() diff --git a/fs/read_write.c b/fs/read_write.c index 336bc8f..72e4775 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -253,6 +253,11 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count loff_t pos; int retval = -EINVAL; +#ifdef CONFIG_KRG_FAF + if (file->f_flags & O_FAF_CLT) + inode = NULL; + else +#endif inode = file->f_path.dentry->d_inode; if (unlikely((ssize_t) count < 0)) return retval; @@ -260,6 +265,9 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count if (unlikely((pos < 0) || (loff_t) (pos + count) < 0)) return retval; +#ifdef CONFIG_KRG_FAF + if (inode) +#endif if (unlikely(inode->i_flock && mandatory_lock(inode))) { retval = locks_mandatory_area( read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, @@ -858,6 +866,12 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, goto out; if (!(in_file->f_mode & FMODE_READ)) goto fput_in; +#ifdef CONFIG_KRG_FAF + if (in_file->f_flags & O_FAF_CLT) { + in_inode = NULL; /* to please gcc */ + goto check_outfile; + } +#endif retval = -EINVAL; in_inode = in_file->f_path.dentry->d_inode; if (!in_inode) @@ -870,6 +884,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, else if (!(in_file->f_mode & FMODE_PREAD)) goto fput_in; +#ifdef CONFIG_KRG_FAF +check_outfile: +#endif retval = rw_verify_area(READ, in_file, ppos, count); if (retval < 0) goto fput_in; @@ -884,15 +901,35 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, goto fput_in; if (!(out_file->f_mode & FMODE_WRITE)) goto fput_out; +#ifdef CONFIG_KRG_FAF + if (out_file->f_flags & O_FAF_CLT) { + out_inode = NULL; /* to please gcc */ + goto faf_sendfile; + } +#endif retval = -EINVAL; if (!out_file->f_op || !out_file->f_op->sendpage) goto fput_out; out_inode = out_file->f_path.dentry->d_inode; +#ifdef CONFIG_KRG_FAF +faf_sendfile: +#endif retval = rw_verify_area(WRITE, out_file, &out_file->f_pos, count); if (retval < 0) goto fput_out; count = retval; +#ifdef CONFIG_KRG_FAF + if (in_file->f_flags & O_FAF_CLT + || out_file->f_flags & O_FAF_CLT) { + + if (!max) + max = *ppos + count; + + retval = krg_faf_sendfile(out_file, in_file, ppos, count, max); + goto update_stat; + } +#endif if (!max) max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); @@ -920,6 +957,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, #endif retval = do_splice_direct(in_file, ppos, out_file, count, fl); +#ifdef CONFIG_KRG_FAF +update_stat: +#endif if (retval > 0) { add_rchar(current, retval); add_wchar(current, retval); diff --git a/include/kerrighed/faf.h b/include/kerrighed/faf.h index c239892..39690ad 100644 --- a/include/kerrighed/faf.h +++ b/include/kerrighed/faf.h @@ -92,6 +92,8 @@ ssize_t krg_faf_sendmsg(struct file *file, struct msghdr *msg, size_t total_len); ssize_t krg_faf_recvmsg(struct file *file, struct msghdr *msg, size_t total_len, unsigned int flags); +ssize_t krg_faf_sendfile(struct file *out, struct file *in, loff_t *ppos, + size_t count, loff_t max); int krg_faf_poll_wait(struct file *file, int wait); void krg_faf_poll_dequeue(struct file *file); diff --git a/kerrighed/fs/faf/faf_hooks.c b/kerrighed/fs/faf/faf_hooks.c index c8961d6..f6af126 100644 --- a/kerrighed/fs/faf/faf_hooks.c +++ b/kerrighed/fs/faf/faf_hooks.c @@ -28,6 +28,7 @@ #include <kerrighed/hotplug.h> #include <net/krgrpc/rpc.h> #include <net/krgrpc/rpcid.h> +#include <kerrighed/dvfs.h> #include <kerrighed/file.h> #include "../file_struct_io_linker.h" @@ -1513,6 +1514,76 @@ cancel: goto out_end; } +ssize_t krg_faf_sendfile(struct file *out, struct file *in, loff_t *ppos, + size_t count, loff_t max) +{ + faf_client_data_t *out_data, *in_data; + char *buf; + mm_segment_t oldfs; + loff_t outpos; + size_t len; + ssize_t size, total_size, retval; + + if (out->f_flags & O_FAF_CLT) + out_data = out->private_data; + else + out_data = NULL; + + if (in->f_flags & O_FAF_CLT) + in_data = in->private_data; + else + in_data = NULL; + + BUG_ON(!out_data && !in_data); + + /* TODO: simply forward the call */ +/* if (in_data && out_data */ +/* && in_data->server_id && out_data->server_id) */ +/* return 0; */ + + len = count; + if (count > PAGE_SIZE) + len = PAGE_SIZE; + + oldfs = get_fs(); + set_fs(KERNEL_DS); + + buf = kmalloc(len, GFP_KERNEL); + if (!buf) { + retval = -ENOMEM; + goto out; + } + + total_size = 0; + + while (count != 0) { + size = vfs_read(in, buf, len, ppos); + if (size < 0) { + retval = size; + goto reset_fs; + } + + outpos = file_pos_read(out); + retval = vfs_write(out, buf, size, &outpos); + if (retval < 0) + goto reset_fs; + + total_size += size; + count -= size; + len = count; + if (count > PAGE_SIZE) + len = PAGE_SIZE; + } + + retval = total_size; + +reset_fs: + set_fs(oldfs); + kfree(buf); +out: + return retval; +} + void krg_faf_srv_close(struct file *file) { check_close_faf_srv_file(file); commit 9383856e21bc97dbfb77238eb74191ab0547ece0 Author: Matthieu Fertré <mat...@ke...> Date: Tue Jun 22 15:03:14 2010 +0200 krgfaf: getdents: allow to be interrupted and fix creds used diff --git a/kerrighed/fs/faf/faf_hooks.c b/kerrighed/fs/faf/faf_hooks.c index ab0f4ad..c8961d6 100644 --- a/kerrighed/fs/faf/faf_hooks.c +++ b/kerrighed/fs/faf/faf_hooks.c @@ -526,7 +526,15 @@ int krg_faf_getdents(struct file *file, enum getdents_filler filler, if (err_rpc) goto cancel; - err_rpc = rpc_unpack_type(desc, err); + err_rpc = pack_creds(desc, current_cred()); + if (err_rpc) + goto cancel; + + err_rpc = unpack_remote_sleep_res_prepare(desc); + if (err_rpc) + goto cancel; + + err_rpc = unpack_remote_sleep_res_type(desc, err); if (err_rpc) goto cancel; diff --git a/kerrighed/fs/faf/faf_server.c b/kerrighed/fs/faf/faf_server.c index 3e68bdf..9bd8720 100644 --- a/kerrighed/fs/faf/faf_server.c +++ b/kerrighed/fs/faf/faf_server.c @@ -440,19 +440,28 @@ cancel: static void handle_faf_getdents(struct rpc_desc *desc, void *__msg, size_t size) { struct faf_getdents_msg *msg = __msg; + const struct cred *old_cred = NULL; struct file *file; - void *dirent; + void *dirent = NULL; int err, err_rpc; - dirent = kmalloc(msg->count, GFP_KERNEL); - if (!dirent) { - err = -ENOMEM; - goto send_error; + old_cred = unpack_override_creds(desc); + if (IS_ERR(old_cred)) { + old_cred = NULL; + goto cancel; } + dirent = kmalloc(msg->count, GFP_KERNEL); + if (!dirent) + goto cancel; + file = fget(msg->server_fd); BUG_ON(!file); + err = remote_sleep_prepare(desc); + if (err) + goto cancel; + switch (msg->filler) { case OLDREADDIR: err = do_oldreaddir(file, dirent, msg->count); @@ -469,20 +478,33 @@ static void handle_faf_getdents(struct rpc_desc *desc, void *__msg, size_t size) break; } + remote_sleep_finish(); fput(file); -send_error: err_rpc = rpc_pack_type(desc, err); - if (err <= 0 || err_rpc) + if (err_rpc) + goto cancel; + + if (err <= 0) goto out; /* err contains the used size of the buffer */ err_rpc = rpc_pack(desc, 0, dirent, err); if (err_rpc) - rpc_cancel(desc); + goto cancel; out: - kfree(dirent); + if (old_cred) + revert_creds(old_cred); + + if (dirent) + kfree(dirent); + + return; + +cancel: + rpc_cancel(desc); + goto out; } /** Handler for doing an IOCTL in a FAF open file. commit 9113791a3242de6969a7f67296c7f8fae3ef26f7 Author: Louis Rilling <lou...@ke...> Date: Wed Jun 23 17:06:32 2010 +0200 Revert "hotplug/add: Accept nodes already online in the nodes_add() syscall" This reverts commit 9da633cb78e774b493b1ec4cc4fb31e9c8ca1a68. It may break userspace expectations, eg when two concurrent # krgadm nodes add --count 1 are launched. Userspace might expect that this adds two nodes, but this patch could make only one node added without notice. Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/kerrighed/hotplug/add.c b/kerrighed/hotplug/add.c index c80020f..0d29aa8 100644 --- a/kerrighed/hotplug/add.c +++ b/kerrighed/hotplug/add.c @@ -128,7 +128,9 @@ static int nodes_add(void __user *arg) if (!krgnodes_subset(ctx->node_set.v, krgnode_present_map)) goto out; - krgnodes_andnot(ctx->node_set.v, ctx->node_set.v, krgnode_online_map); + err = -EPERM; + if (krgnodes_intersects(ctx->node_set.v, krgnode_online_map)) + goto out; err = do_nodes_add(ctx); commit 16b4cb4ebff0d9a88d6d7dbb2a3ecee89fa68c48 Author: Louis Rilling <lou...@ke...> Date: Mon Nov 2 17:58:49 2009 +0100 hotplug/remove: Prepare to automatically remove a node whenever it's Kerrighed container's root task exits The code is not executed right now and will be enabled once minimal support for removing nodes will be implemented. Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/kerrighed/hotplug/cluster.c b/kerrighed/hotplug/cluster.c index f54d67f..5f9e808 100644 --- a/kerrighed/hotplug/cluster.c +++ b/kerrighed/hotplug/cluster.c @@ -319,9 +319,19 @@ void krg_ns_root_exit(struct krg_namespace *ns) if (ns == cluster_init_helper_ns) krg_container_abort(-EAGAIN); +#ifdef CONFIG_KRG_HOTPLUG_DEL + /* TODO: Make it race-free */ + if (!IS_KERRIGHED_NODE(KRGFLAGS_STOPPING) + && IS_KERRIGHED_NODE(KRGFLAGS_RUNNING)) + if (self_remove(ns)) + printk("kerrighed: " + "Failed to automatically remove the node! " + "Please retry manually.\n"); +#else printk(KERN_WARNING "kerrighed: Root task exiting! Leaking zombies.\n"); set_current_state(TASK_UNINTERRUPTIBLE); schedule(); +#endif } /* ns->root_task must be blocked and alive to get a reliable result */ diff --git a/kerrighed/hotplug/hotplug_internal.h b/kerrighed/hotplug/hotplug_internal.h index 5d66fbd..563ee7e 100644 --- a/kerrighed/hotplug/hotplug_internal.h +++ b/kerrighed/hotplug/hotplug_internal.h @@ -21,6 +21,7 @@ struct hotplug_context; int do_cluster_start(struct hotplug_context *ctx); int __nodes_add(struct hotplug_context *ctx); +int self_remove(struct krg_namespace *ns); int repair_monitor(void); void update_heartbeat(void); diff --git a/kerrighed/hotplug/remove.c b/kerrighed/hotplug/remove.c index f4f6b10..4b18358 100644 --- a/kerrighed/hotplug/remove.c +++ b/kerrighed/hotplug/remove.c @@ -141,6 +141,24 @@ static int do_nodes_remove(struct hotplug_context *ctx) return ret; } +int self_remove(struct krg_namespace *ns) +{ + struct hotplug_context *ctx; + int err; + + ctx = hotplug_ctx_alloc(ns); + if (!ctx) + return -ENOMEM; + ctx->node_set.subclusterid = kerrighed_subsession_id; + ctx->node_set.v = krgnodemask_of_node(kerrighed_node_id); + + err = do_nodes_remove(ctx); + + hotplug_ctx_put(ctx); + + return err; +} + static int nodes_remove(void __user *arg) { struct __hotplug_node_set __node_set; commit 2d39f2f748e1eea9336b7145575b9d125339beac Author: Louis Rilling <lou...@ke...> Date: Mon Nov 2 17:18:25 2009 +0100 hotplug/remove: Call krg_ns_root_exit() only before container init's death If container init is exiting, we want to be notified only when the last thread exits before reacting. Also put in krg_ns_root_exit() whatever actions will be needed, and give it the krg_namespace instead of the not-so-meaningful exiting thread. Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/include/kerrighed/namespace.h b/include/kerrighed/namespace.h index 526c56f..ed711f8 100644 --- a/include/kerrighed/namespace.h +++ b/include/kerrighed/namespace.h @@ -35,6 +35,6 @@ static inline void put_krg_ns(struct krg_namespace *ns) bool can_create_krg_ns(unsigned long flags); -void krg_ns_root_exit(struct task_struct *task); +void krg_ns_root_exit(struct krg_namespace *ns); #endif /* __KRG_NAMESPACE_H__ */ diff --git a/kernel/exit.c b/kernel/exit.c index 80473ba..6233ebe 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1126,13 +1126,11 @@ NORET_TYPE void do_exit(long code) exit_irq_thread(); #ifdef CONFIG_KRG_HOTPLUG - if (tsk->nsproxy->krg_ns && tsk == tsk->nsproxy->krg_ns->root_task) { - krg_ns_root_exit(tsk); - printk(KERN_WARNING - "kerrighed: Root task exiting! Leaking zombies.\n"); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule(); - } + group_dead = atomic_dec_and_test(&tsk->signal->live); + if (tsk->nsproxy->krg_ns + && same_thread_group(tsk, tsk->nsproxy->krg_ns->root_task) + && group_dead) + krg_ns_root_exit(tsk->nsproxy->krg_ns); #endif #ifdef CONFIG_KRG_PROC @@ -1153,7 +1151,9 @@ NORET_TYPE void do_exit(long code) acct_update_integrals(tsk); +#ifndef CONFIG_KRG_HOTPLUG group_dead = atomic_dec_and_test(&tsk->signal->live); +#endif if (group_dead) { hrtimer_cancel(&tsk->signal->real_timer); exit_itimers(tsk->signal); diff --git a/kerrighed/hotplug/cluster.c b/kerrighed/hotplug/cluster.c index 9c93ac0..f54d67f 100644 --- a/kerrighed/hotplug/cluster.c +++ b/kerrighed/hotplug/cluster.c @@ -314,11 +314,14 @@ static void krg_container_abort(int err) complete(&cluster_init_helper_ready); } -void krg_ns_root_exit(struct task_struct *task) +void krg_ns_root_exit(struct krg_namespace *ns) { - if (cluster_init_helper_ns - && task->nsproxy->krg_ns == cluster_init_helper_ns) + if (ns == cluster_init_helper_ns) krg_container_abort(-EAGAIN); + + printk(KERN_WARNING "kerrighed: Root task exiting! Leaking zombies.\n"); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule(); } /* ns->root_task must be blocked and alive to get a reliable result */ commit 0f2e8ee95482b45bb8ac00b83b0bd4c6dc057d9b Author: Louis Rilling <lou...@ke...> Date: Thu Oct 29 17:50:47 2009 +0100 hotplug/remove: Introduce membership_online_hold()/release() In order to prevent some Kerrighed services, like process migration, to inject objects to nodes being removed, or to block trying to call a disabled service of a removing node, this commit introduces membership_online_hold()/release() to temporarily prevent remove operations from removing nodes from the online map, which in turn ensures that nodes being removed are kept active. Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/include/kerrighed/hotplug.h b/include/kerrighed/hotplug.h index ab744a4..b814a06 100644 --- a/include/kerrighed/hotplug.h +++ b/include/kerrighed/hotplug.h @@ -84,4 +84,8 @@ extern void (*kh_node_unreachable)(kerrighed_node_t nodeid); void krg_node_arrival(kerrighed_node_t nodeid); void krg_node_departure(kerrighed_node_t nodeid); +void membership_online_hold(void); +int membership_online_try_hold(void); +void membership_online_release(void); + #endif diff --git a/include/linux/cluster_barrier.h b/include/linux/cluster_barrier.h index af13c81..80da290 100644 --- a/include/linux/cluster_barrier.h +++ b/include/linux/cluster_barrier.h @@ -12,6 +12,7 @@ enum static_cluster_barrier_id { CLUSTER_BARRIER_NONE = 0, KDDM_HOTPLUG_BARRIER, SCHED_HOTPLUG_BARRIER, + ONLINE_HOTPLUG_BARRIER, CLUSTER_BARRIER_MAX, }; diff --git a/kerrighed/hotplug/membership.c b/kerrighed/hotplug/membership.c index 01e5408..5fb9e06 100644 --- a/kerrighed/hotplug/membership.c +++ b/kerrighed/hotplug/membership.c @@ -1,9 +1,29 @@ #include <linux/notifier.h> +#include <linux/rwsem.h> +#include <linux/cluster_barrier.h> #include <kerrighed/hotplug.h> #include <kerrighed/krgnodemask.h> #include <kerrighed/sys/types.h> #include <kerrighed/krginit.h> +static DECLARE_RWSEM(online_sem); +static struct cluster_barrier *online_barrier; + +void membership_online_hold(void) +{ + down_read_non_owner(&online_sem); +} + +int membership_online_try_hold(void) +{ + return down_read_trylock_non_owner(&online_sem); +} + +void membership_online_release(void) +{ + up_read_non_owner(&online_sem); +} + static void membership_online_add(krgnodemask_t *vector) { BUG_ON(krgnodes_intersects(*vector, krgnode_online_map)); @@ -12,20 +32,42 @@ static void membership_online_add(krgnodemask_t *vector) kerrighed_nb_nodes += krgnodes_weight(*vector); } -static void membership_online_remove(krgnodemask_t *vector) +static int membership_online_remove(krgnodemask_t *vector) { + krgnodemask_t nodes; + kerrighed_node_t master; + int err; + BUG_ON(!krgnodes_subset(*vector, krgnode_online_map)); + down_write(&online_sem); + + krgnodes_copy(nodes, krgnode_online_map); + master = first_krgnode(nodes); + + err = cluster_barrier(online_barrier, &nodes, master); + if (err) + goto unlock; + krgnodes_andnot(krgnode_online_map, krgnode_online_map, *vector); kerrighed_nb_nodes -= krgnodes_weight(*vector); + + err = cluster_barrier(online_barrier, &nodes, master); + +unlock: + up_write(&online_sem); + + return err; } static void membership_online_clear(krgnodemask_t *vector) { BUG_ON(!krgnode_isset(kerrighed_node_id, *vector)); + down_write(&online_sem); krgnodes_clear(krgnode_online_map); kerrighed_nb_nodes = 0; + up_write(&online_sem); } static @@ -71,6 +113,10 @@ int membership_present_notification(struct notifier_block *nb, int hotplug_membership_init(void) { + online_barrier = alloc_cluster_barrier(ONLINE_HOTPLUG_BARRIER); + if (IS_ERR(online_barrier)) + panic("kerrighed: Couldn't alloc online_barrier!\n"); + register_hotplug_notifier(membership_present_notification, HOTPLUG_PRIO_MEMBERSHIP_PRESENT); register_hotplug_notifier(membership_online_notification, commit 5dff30da37d4a3025802574679d0ba8407d1a2c1 Author: Louis Rilling <lou...@ke...> Date: Wed Jun 23 14:29:30 2010 +0200 Introduce down_read_trylock_non_owner() Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index efd348f..14f3611 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -80,11 +80,13 @@ extern void down_write_nested(struct rw_semaphore *sem, int subclass); * proper abstraction for this case is completions. ] */ extern void down_read_non_owner(struct rw_semaphore *sem); +extern int down_read_trylock_non_owner(struct rw_semaphore *sem); extern void up_read_non_owner(struct rw_semaphore *sem); #else # define down_read_nested(sem, subclass) down_read(sem) # define down_write_nested(sem, subclass) down_write(sem) # define down_read_non_owner(sem) down_read(sem) +# define down_read_trylock_non_owner(sem) down_read_trylock(sem) # define up_read_non_owner(sem) up_read(sem) #endif diff --git a/kernel/rwsem.c b/kernel/rwsem.c index cae050b..dcac142 100644 --- a/kernel/rwsem.c +++ b/kernel/rwsem.c @@ -126,6 +126,13 @@ void down_read_non_owner(struct rw_semaphore *sem) EXPORT_SYMBOL(down_read_non_owner); +int down_read_trylock_non_owner(struct rw_semaphore *sem) +{ + return __down_read_trylock(sem); +} + +EXPORT_SYMBOL(down_read_trylock_non_owner); + void down_write_nested(struct rw_semaphore *sem, int subclass) { might_sleep(); commit c229cdad8e5fe9bd57a49fe6148b291fef354f91 Author: Louis Rilling <lou...@ke...> Date: Tue Nov 3 11:44:17 2009 +0100 hotplug/remove: Call init_cluster_barrier() before init_hotplug() Next commit will make init_hotplug() depend on init_cluster_barrier(). Signed-off-by: Louis Rilling <lou...@ke...> diff --git a/kerrighed/hotplug/krginit.c b/kerrighed/hotplug/krginit.c index 950159d..b84f780 10... [truncated message content] |