···88#include <linux/writeback.h>99#include <linux/sysctl.h>1010#include <linux/gfp.h>1111-#include "internal.h"12111312/* A global variable is a bit ugly, but it keeps the code simple */1413int sysctl_drop_caches;15141616-static void drop_pagecache_sb(struct super_block *sb)1515+static void drop_pagecache_sb(struct super_block *sb, void *unused)1716{1817 struct inode *inode, *toput_inode = NULL;1918···3334 iput(toput_inode);3435}35363636-static void drop_pagecache(void)3737-{3838- struct super_block *sb, *n;3939-4040- spin_lock(&sb_lock);4141- list_for_each_entry_safe(sb, n, &super_blocks, s_list) {4242- if (list_empty(&sb->s_instances))4343- continue;4444- sb->s_count++;4545- spin_unlock(&sb_lock);4646- down_read(&sb->s_umount);4747- if (sb->s_root)4848- drop_pagecache_sb(sb);4949- up_read(&sb->s_umount);5050- spin_lock(&sb_lock);5151- __put_super(sb);5252- }5353- spin_unlock(&sb_lock);5454-}5555-5637static void drop_slab(void)5738{5839 int nr_objects;···4869 proc_dointvec_minmax(table, write, buffer, length, ppos);4970 if (write) {5071 if (sysctl_drop_caches & 1)5151- drop_pagecache();7272+ iterate_supers(drop_pagecache_sb, NULL);5273 if (sysctl_drop_caches & 2)5374 drop_slab();5475 }
+9-24
fs/quota/quota.c
···1818#include <linux/quotaops.h>1919#include <linux/types.h>2020#include <linux/writeback.h>2121-#include "../internal.h"22212322static int check_quotactl_permission(struct super_block *sb, int type, int cmd,2423 qid_t id)···4546 return security_quotactl(cmd, type, id, sb);4647}47484949+static void quota_sync_one(struct super_block *sb, void *arg)5050+{5151+ if (sb->s_qcop && sb->s_qcop->quota_sync)5252+ sb->s_qcop->quota_sync(sb, *(int *)arg, 1);5353+}5454+4855static int quota_sync_all(int type)4956{5050- struct super_block *sb, *n;5157 int ret;52585359 if (type >= MAXQUOTAS)5460 return -EINVAL;5561 ret = security_quotactl(Q_SYNC, type, 0, NULL);5656- if (ret)5757- return ret;5858-5959- spin_lock(&sb_lock);6060- list_for_each_entry_safe(sb, n, &super_blocks, s_list) {6161- if (list_empty(&sb->s_instances))6262- continue;6363- if (!sb->s_qcop || !sb->s_qcop->quota_sync)6464- continue;6565-6666- sb->s_count++;6767- spin_unlock(&sb_lock);6868- down_read(&sb->s_umount);6969- if (sb->s_root)7070- sb->s_qcop->quota_sync(sb, type, 1);7171- up_read(&sb->s_umount);7272- spin_lock(&sb_lock);7373- __put_super(sb);7474- }7575- spin_unlock(&sb_lock);7676-7777- return 0;6262+ if (!ret)6363+ iterate_supers(quota_sync_one, &type);6464+ return ret;7865}79668067static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id,
+30
fs/super.c
···392392}393393394394/**395395+ * iterate_supers - call function for all active superblocks396396+ * @f: function to call397397+ * @arg: argument to pass to it398398+ *399399+ * Scans the superblock list and calls given function, passing it400400+ * locked superblock and given argument.401401+ */402402+void iterate_supers(void (*f)(struct super_block *, void *), void *arg)403403+{404404+ struct super_block *sb, *n;405405+406406+ spin_lock(&sb_lock);407407+ list_for_each_entry_safe(sb, n, &super_blocks, s_list) {408408+ if (list_empty(&sb->s_instances))409409+ continue;410410+ sb->s_count++;411411+ spin_unlock(&sb_lock);412412+413413+ down_read(&sb->s_umount);414414+ if (sb->s_root)415415+ f(sb, arg);416416+ up_read(&sb->s_umount);417417+418418+ spin_lock(&sb_lock);419419+ __put_super(sb);420420+ }421421+ spin_unlock(&sb_lock);422422+}423423+424424+/**395425 * get_super - get the superblock of a device396426 * @bdev: device to get the superblock for397427 *
+6-19
fs/sync.c
···7777}7878EXPORT_SYMBOL_GPL(sync_filesystem);79798080+static void sync_one_sb(struct super_block *sb, void *arg)8181+{8282+ if (!(sb->s_flags & MS_RDONLY) && sb->s_bdi)8383+ __sync_filesystem(sb, *(int *)arg);8484+}8085/*8186 * Sync all the data for all the filesystems (called by sys_sync() and8287 * emergency sync)8388 */8489static void sync_filesystems(int wait)8590{8686- struct super_block *sb, *n;8787-8888- spin_lock(&sb_lock);8989- list_for_each_entry_safe(sb, n, &super_blocks, s_list) {9090- if (list_empty(&sb->s_instances))9191- continue;9292- sb->s_count++;9393- spin_unlock(&sb_lock);9494-9595- down_read(&sb->s_umount);9696- if (!(sb->s_flags & MS_RDONLY) && sb->s_root && sb->s_bdi)9797- __sync_filesystem(sb, wait);9898- up_read(&sb->s_umount);9999-100100- /* restart only when sb is no longer on the list */101101- spin_lock(&sb_lock);102102- __put_super(sb);103103- }104104- spin_unlock(&sb_lock);9191+ iterate_supers(sync_one_sb, &wait);10592}1069310794/*