static ssize_t mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct mdd_device *mdd = m->private; char *kernbuf; int rc; ENTRY; if (count >= PAGE_SIZE) RETURN(-EINVAL); OBD_ALLOC(kernbuf, PAGE_SIZE); if (kernbuf == NULL) RETURN(-ENOMEM); if (copy_from_user(kernbuf, buffer, count)) GOTO(out, rc = -EFAULT); kernbuf[count] = 0; rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, CHANGELOG_MINMASK, CHANGELOG_ALLMASK); if (rc == 0) rc = count; out: OBD_FREE(kernbuf, PAGE_SIZE); return rc; }
static int lprocfs_wr_changelog_mask(struct file *file, const char *buffer, unsigned long count, void *data) { struct mdd_device *mdd = data; char *kernbuf; int rc; ENTRY; if (count >= PAGE_CACHE_SIZE) RETURN(-EINVAL); OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE); if (kernbuf == NULL) RETURN(-ENOMEM); if (copy_from_user(kernbuf, buffer, count)) GOTO(out, rc = -EFAULT); kernbuf[count] = 0; rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, CHANGELOG_MINMASK, CHANGELOG_ALLMASK); if (rc == 0) rc = count; out: OBD_FREE(kernbuf, PAGE_CACHE_SIZE); return rc; }
static int lov_verify_lmm(void *lmm, int lmm_bytes, int *stripe_count) { int rc; if (lsm_op_find(le32_to_cpu(*(__u32 *)lmm)) == NULL) { char *buffer; int sz; CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n", le32_to_cpu(*(__u32 *)lmm), lmm_bytes); sz = lmm_bytes * 2 + 1; OBD_ALLOC(buffer, sz); if (buffer != NULL) { int i; for (i = 0; i < lmm_bytes; i++) sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]); buffer[sz] = '\0'; CERROR("%s\n", buffer); OBD_FREE(buffer, sz); } return -EINVAL; } rc = lsm_op_find(le32_to_cpu(*(__u32 *)lmm))->lsm_lmm_verify(lmm, lmm_bytes, stripe_count); return rc; }
static int lmd_parse_string(char **handle, char *ptr) { char *tail; int length; if ((handle == NULL) || (ptr == NULL)) return -EINVAL; if (*handle != NULL) { OBD_FREE(*handle, strlen(*handle) + 1); *handle = NULL; } tail = strchr(ptr, ','); if (tail == NULL) length = strlen(ptr); else length = tail - ptr; OBD_ALLOC(*handle, length + 1); if (*handle == NULL) return -ENOMEM; memcpy(*handle, ptr, length); (*handle)[length] = '\0'; return 0; }
/** * Implementation of ldlm_valblock_ops::lvbo_free for OFD. * * This function frees allocated LVB data if it associated with the given * LDLM resource. * * \param[in] res LDLM resource * * \retval 0 on successful setup * \retval negative value on error */ static int ofd_lvbo_free(struct ldlm_resource *res) { if (res->lr_lvb_data) OBD_FREE(res->lr_lvb_data, res->lr_lvb_len); return 0; }
static int mds_lov_clean(struct obd_device *obd) { struct mds_obd *mds = &obd->u.mds; struct obd_device *osc = mds->mds_lov_obd; ENTRY; if (mds->mds_profile) { class_del_profile(mds->mds_profile); OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1); mds->mds_profile = NULL; } /* There better be a lov */ if (!osc) RETURN(0); if (IS_ERR(osc)) RETURN(PTR_ERR(osc)); obd_register_observer(osc, NULL); /* Give lov our same shutdown flags */ osc->obd_force = obd->obd_force; osc->obd_fail = obd->obd_fail; /* Cleanup the lov */ obd_disconnect(mds->mds_lov_exp); class_manual_cleanup(osc); RETURN(0); }
int client_fid_init(struct obd_device *obd, struct obd_export *exp, enum lu_cli_type type) { struct client_obd *cli = &obd->u.cli; char *prefix; int rc; ENTRY; OBD_ALLOC_PTR(cli->cl_seq); if (cli->cl_seq == NULL) RETURN(-ENOMEM); OBD_ALLOC(prefix, MAX_OBD_NAME + 5); if (prefix == NULL) GOTO(out_free_seq, rc = -ENOMEM); snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); /* Init client side sequence-manager */ rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); OBD_FREE(prefix, MAX_OBD_NAME + 5); if (rc) GOTO(out_free_seq, rc); RETURN(rc); out_free_seq: OBD_FREE_PTR(cli->cl_seq); cli->cl_seq = NULL; return rc; }
/* temporary for testing */ static int mdc_wr_kuc(struct file *file, const char *buffer, unsigned long count, void *data) { struct obd_device *obd = data; struct kuc_hdr *lh; struct hsm_action_list *hal; struct hsm_action_item *hai; int len; int fd, rc; ENTRY; rc = lprocfs_write_helper(buffer, count, &fd); if (rc) RETURN(rc); if (fd < 0) RETURN(-ERANGE); CWARN("message to fd %d\n", fd); len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + /* for mockup below */ 2 * cfs_size_round(sizeof(*hai)); OBD_ALLOC(lh, len); lh->kuc_magic = KUC_MAGIC; lh->kuc_transport = KUC_TRANSPORT_HSM; lh->kuc_msgtype = HMT_ACTION_LIST; lh->kuc_msglen = len; hal = (struct hsm_action_list *)(lh + 1); hal->hal_version = HAL_VERSION; hal->hal_archive_id = 1; hal->hal_flags = 0; obd_uuid2fsname(hal->hal_fsname, obd->obd_name, MTI_NAME_MAXLEN); /* mock up an action list */ hal->hal_count = 2; hai = hai_zero(hal); hai->hai_action = HSMA_ARCHIVE; hai->hai_fid.f_oid = 5; hai->hai_len = sizeof(*hai); hai = hai_next(hai); hai->hai_action = HSMA_RESTORE; hai->hai_fid.f_oid = 10; hai->hai_len = sizeof(*hai); /* This works for either broadcast or unicast to a single fd */ if (fd == 0) { rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh); } else { cfs_file_t *fp = cfs_get_fd(fd); rc = libcfs_kkuc_msg_put(fp, lh); cfs_put_file(fp); } OBD_FREE(lh, len); if (rc < 0) RETURN(rc); RETURN(count); }
static inline void enc_pools_free(void) { LASSERT(page_pools.epp_max_pools); LASSERT(page_pools.epp_pools); OBD_FREE(page_pools.epp_pools, page_pools.epp_max_pools * sizeof(*page_pools.epp_pools)); }
static int lustre_free_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); LASSERT(lsi != NULL); CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi); /* someone didn't call server_put_mount. */ LASSERT(atomic_read(&lsi->lsi_mounts) == 0); if (lsi->lsi_lmd != NULL) { if (lsi->lsi_lmd->lmd_dev != NULL) OBD_FREE(lsi->lsi_lmd->lmd_dev, strlen(lsi->lsi_lmd->lmd_dev) + 1); if (lsi->lsi_lmd->lmd_profile != NULL) OBD_FREE(lsi->lsi_lmd->lmd_profile, strlen(lsi->lsi_lmd->lmd_profile) + 1); if (lsi->lsi_lmd->lmd_mgssec != NULL) OBD_FREE(lsi->lsi_lmd->lmd_mgssec, strlen(lsi->lsi_lmd->lmd_mgssec) + 1); if (lsi->lsi_lmd->lmd_opts != NULL) OBD_FREE(lsi->lsi_lmd->lmd_opts, strlen(lsi->lsi_lmd->lmd_opts) + 1); if (lsi->lsi_lmd->lmd_exclude_count) OBD_FREE(lsi->lsi_lmd->lmd_exclude, sizeof(lsi->lsi_lmd->lmd_exclude[0]) * lsi->lsi_lmd->lmd_exclude_count); if (lsi->lsi_lmd->lmd_mgs != NULL) OBD_FREE(lsi->lsi_lmd->lmd_mgs, strlen(lsi->lsi_lmd->lmd_mgs) + 1); if (lsi->lsi_lmd->lmd_osd_type != NULL) OBD_FREE(lsi->lsi_lmd->lmd_osd_type, strlen(lsi->lsi_lmd->lmd_osd_type) + 1); if (lsi->lsi_lmd->lmd_params != NULL) OBD_FREE(lsi->lsi_lmd->lmd_params, 4096); OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); } LASSERT(lsi->lsi_llsbi == NULL); OBD_FREE(lsi, sizeof(*lsi)); s2lsi_nocast(sb) = NULL; return 0; }
static void null_free_rs(struct ptlrpc_reply_state *rs) { LASSERT_ATOMIC_GT(&rs->rs_svc_ctx->sc_refcount, 1); cfs_atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) OBD_FREE(rs, rs->rs_size); }
static void null_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { LASSERT(req->rq_repbuf); OBD_FREE(req->rq_repbuf, req->rq_repbuf_len); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; }
/* should NOT be called with the dcache lock, see fs/dcache.c */ static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; ENTRY; LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) /* NFS copies the de->d_op methods (bug 4655) */ RETURN_EXIT; if (lld->lld_it) { ll_intent_release(lld->lld_it); OBD_FREE(lld->lld_it, sizeof(*lld->lld_it)); } LASSERT(lld->lld_cwd_count == 0); LASSERT(lld->lld_mnt_count == 0); OBD_FREE(de->d_fsdata, sizeof(*lld)); EXIT; }
static int enc_pools_add_pages(int npages) { static CFS_DECLARE_MUTEX(sem_add_pages); cfs_page_t ***pools; int npools, alloced = 0; int i, j, rc = -ENOMEM; if (npages < PTLRPC_MAX_BRW_PAGES) npages = PTLRPC_MAX_BRW_PAGES; cfs_down(&sem_add_pages); if (npages + page_pools.epp_total_pages > page_pools.epp_max_pages) npages = page_pools.epp_max_pages - page_pools.epp_total_pages; LASSERT(npages > 0); page_pools.epp_st_grows++; npools = npages_to_npools(npages); OBD_ALLOC(pools, npools * sizeof(*pools)); if (pools == NULL) goto out; for (i = 0; i < npools; i++) { OBD_ALLOC(pools[i], CFS_PAGE_SIZE); if (pools[i] == NULL) goto out_pools; for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) { pools[i][j] = cfs_alloc_page(CFS_ALLOC_IO | CFS_ALLOC_HIGH); if (pools[i][j] == NULL) goto out_pools; alloced++; } } LASSERT(alloced == npages); enc_pools_insert(pools, npools, npages); CDEBUG(D_SEC, "added %d pages into pools\n", npages); rc = 0; out_pools: enc_pools_cleanup(pools, npools); OBD_FREE(pools, npools * sizeof(*pools)); out: if (rc) { page_pools.epp_st_grow_fails++; CERROR("Failed to allocate %d enc pages\n", npages); } cfs_up(&sem_add_pages); return rc; }
static int enc_pools_add_pages(int npages) { static DEFINE_MUTEX(add_pages_mutex); struct page ***pools; int npools, alloced = 0; int i, j, rc = -ENOMEM; if (npages < PTLRPC_MAX_BRW_PAGES) npages = PTLRPC_MAX_BRW_PAGES; mutex_lock(&add_pages_mutex); if (npages + page_pools.epp_total_pages > page_pools.epp_max_pages) npages = page_pools.epp_max_pages - page_pools.epp_total_pages; LASSERT(npages > 0); page_pools.epp_st_grows++; npools = npages_to_npools(npages); OBD_ALLOC(pools, npools * sizeof(*pools)); if (pools == NULL) goto out; for (i = 0; i < npools; i++) { OBD_ALLOC(pools[i], PAGE_CACHE_SIZE); if (pools[i] == NULL) goto out_pools; for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) { pools[i][j] = alloc_page(GFP_NOFS | __GFP_HIGHMEM); if (pools[i][j] == NULL) goto out_pools; alloced++; } } LASSERT(alloced == npages); enc_pools_insert(pools, npools, npages); CDEBUG(D_SEC, "added %d pages into pools\n", npages); rc = 0; out_pools: enc_pools_cleanup(pools, npools); OBD_FREE(pools, npools * sizeof(*pools)); out: if (rc) { page_pools.epp_st_grow_fails++; CERROR("Failed to allocate %d enc pages\n", npages); } mutex_unlock(&add_pages_mutex); return rc; }
void osd_oi_fini(struct osd_thread_info *info, struct osd_device *osd) { if (unlikely(osd->od_oi_table == NULL)) return; osd_oi_table_put(info, osd->od_oi_table, osd->od_oi_count); OBD_FREE(osd->od_oi_table, sizeof(*(osd->od_oi_table)) * OSD_OI_FID_NR_MAX); osd->od_oi_table = NULL; }
/* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) { const char *s1 = ptr, *s2; __u32 index, *exclude_list; int rc = 0, devmax; /* The shortest an ost name can be is 8 chars: -OST0000. We don't actually know the fsname at this time, so in fact a user could specify any fsname. */ devmax = strlen(ptr) / 8 + 1; /* temp storage until we figure out how many we have */ OBD_ALLOC(exclude_list, sizeof(index) * devmax); if (!exclude_list) return -ENOMEM; /* we enter this fn pointing at the '=' */ while (*s1 && *s1 != ' ' && *s1 != ',') { s1++; rc = server_name2index(s1, &index, &s2); if (rc < 0) { CERROR("Can't parse server name '%s': rc = %d\n", s1, rc); break; } if (rc == LDD_F_SV_TYPE_OST) exclude_list[lmd->lmd_exclude_count++] = index; else CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n", (uint)(s2-s1), s1, rc); s1 = s2; /* now we are pointing at ':' (next exclude) or ',' (end of excludes) */ if (lmd->lmd_exclude_count >= devmax) break; } if (rc >= 0) /* non-err */ rc = 0; if (lmd->lmd_exclude_count) { /* permanent, freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_exclude, sizeof(index) * lmd->lmd_exclude_count); if (lmd->lmd_exclude) { memcpy(lmd->lmd_exclude, exclude_list, sizeof(index) * lmd->lmd_exclude_count); } else { rc = -ENOMEM; lmd->lmd_exclude_count = 0; } } OBD_FREE(exclude_list, sizeof(index) * devmax); return rc; }
int filter_log_sz_change(struct llog_handle *cathandle, struct ll_fid *mds_fid, __u32 ioepoch, struct llog_cookie *logcookie, struct inode *inode) { struct llog_size_change_rec *lsc; int rc; struct ost_filterdata *ofd; ENTRY; LOCK_INODE_MUTEX(inode); ofd = INODE_PRIVATE_DATA(inode); if (ofd && ofd->ofd_epoch >= ioepoch) { if (ofd->ofd_epoch > ioepoch) CERROR("client sent old epoch %d for obj ino %ld\n", ioepoch, inode->i_ino); UNLOCK_INODE_MUTEX(inode); RETURN(0); } if (ofd && ofd->ofd_epoch < ioepoch) { ofd->ofd_epoch = ioepoch; } else if (!ofd) { OBD_ALLOC(ofd, sizeof(*ofd)); if (!ofd) GOTO(out, rc = -ENOMEM); igrab(inode); INODE_PRIVATE_DATA(inode) = ofd; ofd->ofd_epoch = ioepoch; } /* the decision to write a record is now made, unlock */ UNLOCK_INODE_MUTEX(inode); OBD_ALLOC(lsc, sizeof(*lsc)); if (lsc == NULL) RETURN(-ENOMEM); lsc->lsc_hdr.lrh_len = lsc->lsc_tail.lrt_len = sizeof(*lsc); lsc->lsc_hdr.lrh_type = OST_SZ_REC; lsc->lsc_fid = *mds_fid; lsc->lsc_ioepoch = ioepoch; rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie, NULL); OBD_FREE(lsc, sizeof(*lsc)); if (rc > 0) { LASSERT(rc == sizeof(*logcookie)); rc = 0; } out: RETURN(rc); }
/* * helper function to generate the filename associated with a slave index file */ static inline int lquota_disk_slv_filename(const struct lu_fid *glb_fid, struct obd_uuid *uuid, char *filename) { char *name, *uuid_str; /* In most case, the uuid is NULL terminated */ if (uuid->uuid[sizeof(*uuid) - 1] != '\0') { OBD_ALLOC(uuid_str, sizeof(*uuid)); if (uuid_str == NULL) RETURN(-ENOMEM); memcpy(uuid_str, uuid->uuid, sizeof(*uuid) - 1); } else { uuid_str = (char *)uuid->uuid; } /* we strip the slave's UUID (in the form of fsname-OST0001_UUID) of * the filesystem name in case this one is changed in the future */ name = strrchr(uuid_str, '-'); if (name == NULL) { name = strrchr(uuid_str, ':'); if (name == NULL) { CERROR("Failed to extract extract filesystem " "name from UUID %s\n", uuid_str); if (uuid_str != uuid->uuid) OBD_FREE(uuid_str, sizeof(*uuid)); return -EINVAL; } } name++; /* the filename is composed of the most signicant bits of the global * FID, that's to say the oid which encodes the pool id, pool type and * quota type, followed by the export UUID */ sprintf(filename, "0x%x-%s", glb_fid->f_oid, name); if (uuid_str != uuid->uuid) OBD_FREE(uuid_str, sizeof(*uuid)); return 0; }
/* should NOT be called with the dcache lock, see fs/dcache.c */ static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; ENTRY; LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) { /* NFS copies the de->d_op methods (bug 4655) */ EXIT; return; } #ifndef HAVE_VFS_INTENT_PATCHES if (lld->lld_it) { ll_intent_release(lld->lld_it); OBD_FREE(lld->lld_it, sizeof(*lld->lld_it)); } #endif LASSERT(lld->lld_cwd_count == 0); LASSERT(lld->lld_mnt_count == 0); OBD_FREE(de->d_fsdata, sizeof(*lld)); EXIT; }
static struct lu_device *lov_device_free(const struct lu_env *env, struct lu_device *d) { struct lov_device *ld = lu2lov_dev(d); const int nr = ld->ld_target_nr; cl_device_fini(lu2cl_dev(d)); if (ld->ld_target != NULL) OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0])); if (ld->ld_emrg != NULL) lov_emerg_free(ld->ld_emrg, nr); OBD_FREE_PTR(ld); return NULL; }
int llu_iop_lookup(struct pnode *pnode, struct inode **inop, struct intent *intnt, const char *path) { struct lookup_intent *it; int rc; ENTRY; liblustre_wait_event(0); *inop = NULL; /* the mount root inode have no name, so don't call * remote in this case. but probably we need revalidate * it here? FIXME */ if (pnode->p_mount->mnt_root == pnode) { struct inode *i = pnode->p_base->pb_ino; *inop = i; RETURN(0); } if (!pnode->p_base->pb_name.len) RETURN(-EINVAL); it = translate_lookup_intent(intnt, path); /* param flags is not used, let it be 0 */ if (llu_pb_revalidate(pnode, 0, it)) { LASSERT(pnode->p_base->pb_ino); *inop = pnode->p_base->pb_ino; GOTO(out, rc = 0); } rc = llu_lookup_it(pnode->p_parent->p_base->pb_ino, pnode, it, 0); if (!rc) { if (!pnode->p_base->pb_ino) rc = -ENOENT; else *inop = pnode->p_base->pb_ino; } out: if (it) OBD_FREE(it, sizeof(*it)); liblustre_wait_event(0); RETURN(rc); }
void osp_lprocfs_init(struct osp_device *osp) { struct obd_device *obd = osp->opd_obd; struct proc_dir_entry *osc_proc_dir; int rc; obd->obd_proc_entry = lprocfs_register(obd->obd_name, obd->obd_type->typ_procroot, lprocfs_osp_osd_vars, &osp->opd_dt_dev); if (IS_ERR(obd->obd_proc_entry)) { CERROR("%s: can't register in lprocfs: %ld\n", obd->obd_name, PTR_ERR(obd->obd_proc_entry)); obd->obd_proc_entry = NULL; return; } rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd); if (rc) { CERROR("%s: can't register in lprocfs: %ld\n", obd->obd_name, PTR_ERR(obd->obd_proc_entry)); return; } ptlrpc_lprocfs_register_obd(obd); /* for compatibility we link old procfs's OSC entries to osp ones */ if (!osp->opd_connect_mdt) { osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc"); if (osc_proc_dir) { cfs_proc_dir_entry_t *symlink = NULL; char *name; OBD_ALLOC(name, strlen(obd->obd_name) + 1); if (name == NULL) return; strcpy(name, obd->obd_name); if (strstr(name, "osc")) symlink = lprocfs_add_symlink(name, osc_proc_dir, "../osp/%s", obd->obd_name); OBD_FREE(name, strlen(obd->obd_name) + 1); osp->opd_symlink = symlink; } } }
/* * Free llog handle and header data if exists. Used in llog_close() only */ void llog_free_handle(struct llog_handle *loghandle) { LASSERT(loghandle != NULL); /* failed llog_init_handle */ if (!loghandle->lgh_hdr) goto out; if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) LASSERT(list_empty(&loghandle->u.phd.phd_entry)); else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) LASSERT(list_empty(&loghandle->u.chd.chd_head)); LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE); OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE); out: OBD_FREE_PTR(loghandle); }
static void null_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { if (!req->rq_pool) { LASSERTF(req->rq_reqmsg == req->rq_reqbuf, "req %p: reqmsg %p is not reqbuf %p in null sec\n", req, req->rq_reqmsg, req->rq_reqbuf); LASSERTF(req->rq_reqbuf_len >= req->rq_reqlen, "req %p: reqlen %d should smaller than buflen %d\n", req, req->rq_reqlen, req->rq_reqbuf_len); OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } }
static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) { int i; for (i = 0; i < nr; ++i) { struct lov_device_emerg *em; em = emrg[i]; if (em != NULL) { LASSERT(em->emrg_page_list.pl_nr == 0); if (em->emrg_env != NULL) cl_env_put(em->emrg_env, &em->emrg_refcheck); OBD_FREE_PTR(em); } } OBD_FREE(emrg, nr * sizeof(emrg[0])); }
/* * could be called frequently for query (@nr_to_scan == 0). * we try to keep at least PTLRPC_MAX_BRW_PAGES pages in the pool. */ static int enc_pools_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) { struct shrink_control scv = { .nr_to_scan = shrink_param(sc, nr_to_scan), .gfp_mask = shrink_param(sc, gfp_mask) }; #if !defined(HAVE_SHRINKER_WANT_SHRINK_PTR) && !defined(HAVE_SHRINK_CONTROL) struct shrinker* shrinker = NULL; #endif enc_pools_shrink_scan(shrinker, &scv); return enc_pools_shrink_count(shrinker, &scv); } #endif /* HAVE_SHRINKER_COUNT */ static inline int npages_to_npools(unsigned long npages) { return (int) ((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); } /* * return how many pages cleaned up. */ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) { unsigned long cleaned = 0; int i, j; for (i = 0; i < npools; i++) { if (pools[i]) { for (j = 0; j < PAGES_PER_POOL; j++) { if (pools[i][j]) { __free_page(pools[i][j]); cleaned++; } } OBD_FREE(pools[i], PAGE_CACHE_SIZE); pools[i] = NULL; } } return cleaned; }
static void mdt_identity_entry_free(struct upcall_cache *cache, struct upcall_cache_entry *entry) { struct md_identity *identity = &entry->u.identity; if (identity->mi_ginfo) { cfs_put_group_info(identity->mi_ginfo); identity->mi_ginfo = NULL; } if (identity->mi_nperms) { LASSERT(identity->mi_perms); OBD_FREE(identity->mi_perms, identity->mi_nperms * sizeof(struct md_perm)); identity->mi_nperms = 0; } }
int llu_md_close(struct obd_export *md_exp, struct inode *inode) { struct llu_inode_info *lli = llu_i2info(inode); struct ll_file_data *fd = lli->lli_file_data; struct ptlrpc_request *req = NULL; struct obd_client_handle *och = &fd->fd_mds_och; struct intnl_stat *st = llu_i2stat(inode); struct md_op_data op_data = { { 0 } }; int rc; ENTRY; /* clear group lock, if present */ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) llu_put_grouplock(inode, fd->fd_grouplock.cg_gid); llu_prepare_close(inode, &op_data, fd); rc = md_close(md_exp, &op_data, och->och_mod, &req); if (rc == -EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ LASSERT(lli->lli_open_flags & FMODE_WRITE); rc = llu_som_update(inode, &op_data); if (rc) { CERROR("inode %llu mdc Size-on-MDS update failed: " "rc = %d\n", (long long)st->st_ino, rc); rc = 0; } } else if (rc) { CERROR("inode %llu close failed: rc %d\n", (long long)st->st_ino, rc); } else { rc = llu_objects_destroy(req, inode); if (rc) CERROR("inode %llu ll_objects destroy: rc = %d\n", (long long)st->st_ino, rc); } md_clear_open_replay_data(md_exp, och); ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; lli->lli_file_data = NULL; OBD_FREE(fd, sizeof(*fd)); RETURN(rc); }
int llog_catinfo(struct ptlrpc_request *req) { struct obd_export *exp = req->rq_export; struct obd_device *obd = exp->exp_obd; char *keyword; char *buf, *reply; int rc; ENTRY; OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (buf == NULL) RETURN(-ENOMEM); memset(buf, 0, LLOG_CHUNK_SIZE); keyword = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LASSERT(keyword); if (strcmp(keyword, "config") == 0) { char *client = req_capsule_client_get(&req->rq_pill, &RMF_STRING); LASSERT(client); rc = llog_catinfo_config(obd, buf, LLOG_CHUNK_SIZE, client); } else if (strcmp(keyword, "deletions") == 0) { rc = llog_catinfo_deletions(obd, buf, LLOG_CHUNK_SIZE); } else { rc = -EOPNOTSUPP; } req_capsule_set_size(&req->rq_pill, &RMF_STRING, RCL_SERVER, LLOG_CHUNK_SIZE); rc = req_capsule_server_pack(&req->rq_pill); if (rc) GOTO(out_free, rc = -ENOMEM); reply = req_capsule_server_get(&req->rq_pill, &RMF_STRING); if (strlen(buf) == 0) sprintf(buf, "%s", "No log informations\n"); memcpy(reply, buf, LLOG_CHUNK_SIZE); EXIT; out_free: OBD_FREE(buf, LLOG_CHUNK_SIZE); return rc; }