What is a dirty inode and what are dirty bytes ?

What is a Dirtied inode

It is a  common computer term that data in a  cache is "clean" when it  has been  synchronized, and  "dirty" when  it is  different.  A dirty inode  has had new data written  into it but it  has not been
written to disk.

source : http://serverfault.com/questions/56374/dirtied-inode
dirty_inode: this method is called by the VFS to mark an inode dirty.

What are dirty_bytes

Contains the amount  of dirty memory at which  a process generating disk writes will itself  start writeback.  Note: dirty_bytes is the counterpart of dirty_ratio. Only one  of them may be specified
at a time.  When one  sysctl is  written  it is  immediately taken  into account to evaluate  the dirty
memory limits and  the other appears as 0 when read.  Note: the minimum value allowed for dirty_bytes is
two  pages (in  bytes); any  value lower  than this  limit  will be ignored and the old configuration
will be retained.

source: http://kernel.org/doc/Documentation/sysctl/vm.txt

RELATED SHELL SESSION EXPOSURE
[bash light=”true”]
$cat /proc/sys/vm/dirty_background_bytes
0
$echo 1 > /proc/sys/vm/dirty_background_bytes
$cat /proc/sys/vm/dirty_background_bytes
1
$echo 1 > /proc/sys/vm/dirty_
dirty_background_bytes dirty_bytes dirty_ratio
dirty_background_ratio dirty_expire_centisecs dirty_writeback_centisecs
$echo 1 > /proc/sys/vm/dirty_background_ratio

$echo 1 > /proc/sys/vm/dirty_background_ratio
$echo 0 > /proc/sys/vm/dirty_background_ratio
$cat /proc/sys/vm/dirty_bytes
0
$echo 1 > /proc/sys/vm/dirty_bytes
$echo 1 > /proc/sys/vm/
block_dump legacy_va_layout numa_zonelist_order
compact_memory lowmem_reserve_ratio oom_dump_tasks
dirty_background_bytes max_map_count oom_kill_allocating_task
dirty_background_ratio memory_failure_early_kill overcommit_memory
dirty_bytes memory_failure_recovery overcommit_ratio
dirty_expire_centisecs min_free_kbytes page-cluster
dirty_ratio min_slab_ratio panic_on_oom
dirty_writeback_centisecs min_unmapped_ratio percpu_pagelist_fraction
drop_caches mmap_min_addr scan_unevictable_pages
extfrag_threshold nr_hugepages stat_interval
hugepages_treat_as_movable nr_hugepages_mempolicy swappiness
hugetlb_shm_group nr_overcommit_hugepages vfs_cache_pressure
laptop_mode nr_pdflush_threads zone_reclaim_mode
$echo 1 > /proc/sys/vm/dirty_expire_centisecs
$echo 1 > /proc/sys/vm/dirty_writeback_centisecs
$

[/bash]
RELATED SOURCE CODE EXPOSURE
[c light=”true”]
/*
* ext4_dirty_inode() is called from __mark_inode_dirty()
*
* We’re really interested in the case where a file is being extended.
* i_size has been changed by generic_commit_write() and we thus need
* to include the updated inode in the current transaction.
*
* Also, dquot_alloc_block() will always dirty the inode when blocks
* are allocated to the file.
*
* If the inode is marked synchronous, we don’t honour that here – doing
* so would cause a commit on atime updates, which we don’t bother doing.
* We handle synchronous inodes at the highest possible level.
*
* If only the I_DIRTY_TIME flag is set, we can skip everything. If
* I_DIRTY_TIME and I_DIRTY_SYNC is set, the only inode fields we need
* to copy into the on-disk inode structure are the timestamp files.
*/
void ext4_dirty_inode(struct inode *inode, int flags)
{
handle_t *handle;

if (flags == I_DIRTY_TIME)
return;
handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
if (IS_ERR(handle))
goto out;

ext4_mark_inode_dirty(handle, inode);

ext4_journal_stop(handle);
out:
return;
}
[/c]
SOURCE CODE TAKEN FROM OFFICIAL LINUX KERNEL
LINKS
https://www.kernel.org/doc/Documentation/filesystems/vfs.txt
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/inode.c?h=v4.20-rc3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s