/* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright © 2001-2007 Red Hat, Inc. * * Created by David Woodhouse <[email protected]> * * For licensing information, see the file 'LICENCE' in this directory. * */ #define pr_fmt(fmt) … #include <linux/kernel.h> #include <linux/mtd/mtd.h> #include <linux/compiler.h> #include <linux/sched/signal.h> #include "nodelist.h" #include "debug.h" /* * Check whether the user is allowed to write. */ static int jffs2_rp_can_write(struct jffs2_sb_info *c) { … } static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *len, uint32_t sumsize); /** * jffs2_reserve_space - request physical space to write nodes to flash * @c: superblock info * @minsize: Minimum acceptable size of allocation * @len: Returned value of allocation length * @prio: Allocation type - ALLOC_{NORMAL,DELETION} * @sumsize: summary size requested or JFFS2_SUMMARY_NOSUM_SIZE for no summary * * Requests a block of physical space on the flash. * * Returns: %0 for success and puts 'len' into the appropriate place, * or returns -ENOSPC or other error if appropriate. * Doesn't return len since that's already returned in @len. * * If it returns %0, jffs2_reserve_space() also downs the per-filesystem * allocation semaphore, to prevent more than one allocation from being * active at any time. The semaphore is later released by jffs2_commit_allocation(). * * jffs2_reserve_space() may trigger garbage collection in order to make room * for the requested allocation. */ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *len, int prio, uint32_t sumsize) { … } int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *len, uint32_t sumsize) { … } /* Classify nextblock (clean, dirty of verydirty) and force to select an other one */ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) { … } /* Select a new jeb for nextblock */ static int jffs2_find_nextblock(struct jffs2_sb_info *c) { … } /* Called with alloc sem _and_ erase_completion_lock */ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *len, uint32_t sumsize) { … } /** * jffs2_add_physical_node_ref - add a physical node reference to the list * @c: superblock info * @ofs: offset in the block * @len: length of this physical node * @ic: inode cache pointer * * Should only be used to report nodes for which space has been allocated * by jffs2_reserve_space. * * Must be called with the alloc_sem held. * * Returns: pointer to new node on success or -errno code on error */ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, uint32_t ofs, uint32_t len, struct jffs2_inode_cache *ic) { … } void jffs2_complete_reservation(struct jffs2_sb_info *c) { … } static inline int on_list(struct list_head *obj, struct list_head *head) { … } void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref) { … } int jffs2_thread_should_wake(struct jffs2_sb_info *c) { … }