/** Check if we need to close a FAF server file. * @author Renaud Lottiaux * * @param file The file to check. * * We can close a FAF server file if local f_count == 1 and DVFS count == 1. * This means the FAF server is the last process cluster wide using the file. */ void check_close_faf_srv_file(struct file *file) { struct dvfs_file_struct *dvfs_file; unsigned long objid = file->f_objid; int close_file = 0; /* Pre-check the file count to avoid a useless call to get_dvfs */ if (file_count (file) != 1) return; dvfs_file = get_dvfs_file_struct(objid); /* If dvfs file is NULL, someone else did the job before us */ if (dvfs_file->file == NULL) goto done; BUG_ON (dvfs_file->file != file); /* Re-check f_count in case it changed during the get_dvfs */ if ((dvfs_file->count == 1) && (file_count (file) == 1)) { /* The FAF server file is the last one used in the cluster. * We can now close it. */ close_file = 1; dvfs_file->file = NULL; } done: put_dvfs_file_struct (objid); if (close_file) close_faf_file(file); }
int end_import_dvfs_file(unsigned long dvfs_objid, struct dvfs_file_struct *dvfs_file, struct file *file, int first_import) { int r = 0; if (IS_ERR(file)) { r = PTR_ERR (file); goto error; } if (first_import) { /* This is the first time the file is imported on this node * Setup the DVFS file field and inc the DVFS counter. */ file->f_objid = dvfs_objid; dvfs_file->file = file; dvfs_file->count++; } error: put_dvfs_file_struct(dvfs_objid); return r; }