Multiple Device Driver and Flash FTL Sarah Diesburg COP 5641.

Slides:



Advertisements
Similar presentations
I/O Management and Disk Scheduling Chapter 11. I/O Driver OS module which controls an I/O device hides the device specifics from the above layers in the.
Advertisements

Chapter 12: File System Implementation
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Flash storage memory and Design Trade offs for SSD performance
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Disks and RAID.
Full-Datapath Secure Deletion Sarah Diesburg 1. Overview Problem  Current secure deletion methods do not work State of the art  Optimistic system-wide.
Chapter 10: File-System Interface
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Embedded Real-Time Systems Design Selecting memory.
Overview: Memory Memory Organization: General Issues (Hardware) –Objectives in Memory Design –Memory Types –Memory Hierarchies Memory Management (Software.
Solid State Drive Feb 15. NAND Flash Memory Main storage component of Solid State Drive (SSD) USB Drive, cell phone, touch pad…
An Introduction to Device Drivers Sarah Diesburg COP 5641 / CIS 4930.
Week 10 Project 3: An Introduction to File Systems
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
Operating Systems CMPSC 473 I/O Management (2) December Lecture 24 Instructor: Bhuvan Urgaonkar.
File system support on Multi Level Cell (MLC) flash in open source April 17, 2008 Kyungmin Park Software Laboratories Samsung Electronics.
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
Making a Phone Call with Phase Change Memory Justin Treon Embedded Linux Conference Session W-130-C April 15, 2008.
Seminar on Linux-based embedded systems
TrueErase: Secure Deletion on Flash Storage Sarah Diesburg, Chris Meyers, An-I Andy Wang 10/8/2015.
1 Project 3: An Introduction to File Systems CS3430 Operating Systems University of Northern Iowa.
Full-Datapath Secure Data Deletion Sarah Diesburg 5/4/
Lecture 10 Page 1 CS 111 Summer 2013 File Systems: Introduction CS 111 Operating Systems Peter Reiher.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Design of Flash-Based DBMS: An In-Page Logging Approach Sang-Won Lee and Bongki Moon Presented by Chris Homan.
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
File System Implementation
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Lecture 3 Page 1 CS 111 Online Disk Drives An especially important and complex form of I/O device Still the primary method of providing stable storage.
IRON for JFFS2 Presented by: Abhinav Kumar Raja Ram Yadhav Ramakrishnan.
An Introduction to Device Drivers Ted Baker  Andy Wang COP 5641 / CIS 4930.
Operating Systems CMPSC 473 I/O Management (3) December 07, Lecture 24 Instructor: Bhuvan Urgaonkar.
CS333 Intro to Operating Systems Jonathan Walpole.
B LOCK L AYER S UBSYSTEM Linux Kernel Programming CIS 4930/COP 5641.
Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Implementation.
Lecture 22 SSD. LFS review Good for …? Bad for …? How to write in LFS? How to read in LFS?
4P13 Week 12 Talking Points Device Drivers 1.Auto-configuration and initialization routines 2.Routines for servicing I/O requests (the top half)
COMP 3438 – Part I - Lecture 5 Character Device Drivers
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
XIP – eXecute In Place Jiyong Park. 2 Contents Flash Memory How to Use Flash Memory Flash Translation Layers (Traditional) JFFS JFFS2 eXecute.
W4118 Operating Systems Instructor: Junfeng Yang.
Application-Managed Flash
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Module 12: I/O Systems I/O hardware Application I/O Interface
Jonathan Walpole Computer Science Portland State University
CE 454 Computer Architecture
Chapter 12: File System Implementation
Work-in-Progress: Full-Datapath Secure Deletion
CSE451 I/O Systems and the Full I/O Path Autumn 2002
TrueErase: Secure Deletion on Electronic Storage
Linux Kernel Driver.
Project 3: An Introduction to File Systems
Device-mapper RAID tool Linux-Kongress Hamburg 2005
Introduction to the Kernel and Device Drivers
An Introduction to Device Drivers
מערכות הפעלה ערן טרומר סמסטר א' תשע"ב
Virtual Memory Hardware
Storage Systems Sudhanva Gurumurthi.
PARAMETER-AWARE I/O MANAGEMENT FOR SOLID STATE DISKS
Lecture 11: Flash Memory and File System Abstraction
Sarah Diesburg Operating Systems COP 4610
Introduction to Operating Systems
Presentation transcript:

Multiple Device Driver and Flash FTL Sarah Diesburg COP 5641

Introduction Kernel uses logical remapping layers over storage to hide complexity and add functionality Two examples Multiple device drivers Flash Translation Layer (FTL)

The md driver Provides virtual devices Created from one or more independent underlying devices The basic mechanism to support RAIDs Full-disk encryption (software) LVM Secure deletion (TrueErase)

The md driver File systems mounted on top of device mapper virtual device Virtual device can Abstract multiple devices Perform encryption Other things User/Kernel Applications DM File System

Simple Device Mappers Linear Maps a linear range of a device Delay delays reads and/or writes and maps them to different devices Zero provides a block-device that always returns zero'd data on reads and silently drops writes similar behavior to /dev/zero, but as a block-device instead of a character-device. Flakey Used for testing only, simulates intermittent, catastrophic device failure mapper mapper

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Logical start sector

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Command to get number of sectors of a device (like /dev/sda1)

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Type of device mapper device we want. Linear is a one-to-one logical to physical sector mapping.

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Linear parameters: base device (like /dev/sda1)

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Linear parameters: starting offset within the device

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity Pipe the command to dmsetup, acts like “table_file” parameter

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity dmsetup command manages logical devices that use the device mapper driver. See ‘man dmsetup’ for more information.

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity We wish to “create” a new logical device mapper device.

Loading a device mapper #!/bin/sh # Create an identity mapping for a device echo "0 `blockdev --getsize $1` linear $1 0" \ | dmsetup create identity We name the new device “identity”.

Loading a device mapper Can then mount file system directly on top of virtual device #!/bin/bash mount /dev/mapper/identity /mnt

Unloading a device mapper #!/bin/bash umount /mnt dmsetup remove identity

Unloading a device mapper #!/bin/bash umount /mnt dmsetup remove identity First unmount the file system

Unloading a device mapper #!/bin/bash umount /mnt dmsetup remove identity Then use dmsetup to remove the device called identity

dm-linear.c Documentation tion/device-mapper/linear.txt tion/device-mapper/linear.txt Code dm-linear.c dm-linear.c

static struct target_type linear_target = {.name = "linear",.version = {1, 1, 0},.module = THIS_MODULE,.ctr = linear_ctr,.dtr = linear_dtr,.map = linear_map,.status = linear_status,.ioctl = linear_ioctl,.merge = linear_merge,.iterate_devices = linear_iterate_devices, };

linear_map static int linear_map(struct dm_target *ti, struct bio *bio, union map_info *map_context) { struct linear_c *lc = (struct linear_c *) ti->private; bio->bi_bdev = lc->dev->bdev; bio->bi_sector = lc->start + (bio->bi_sector - ti->begin); return DM_MAPIO_REMAPPED; } (**Note – this is a simpler function from an earlier kernel version. Version 3.2 does the same, but with a few more helper functions)

Memory Technology Device Different than a character or block device Exports a special character device with extra ioctls and operations to access flash storage For raw flash devices (not USB sticks) Embedded chips

NAND Flash Characteristics Flash has different constraints than hard drives or character devices Exports read, write, and erase operations

NAND Flash Characteristics Can only write to a freshly-erased location If you want to write again to same physical location, you must first erase the area Reads and writes are to smaller flash pages Erasures are performed in flash blocks Holds many flash pages

NAND Flash Characteristics Each storage location can be erased only 10K-1M times Writing is slower than reading Erasures can be 10x slower than writing Each NAND page has a small, non- addressable out-of-bounds area to hold state and mapping information Accessed by ioctls

NAND Flash Characteristics We need a way to not wear out the flash and have good performance with a minimum of writes and erases

Flash Translation Layer The solution is to stack a flash translation layer (FTL) on top of the raw flash device Exports a block device Takes care of the flash operations of reads, writes, and erases Evenly wears writes to all flash locations Marks old pages as invalid until they can be erased later

Data Path Virtual file system (VFS) File system Multi-device drivers Ext3 Disk driver MTD driver JFFS2 FTL Apps

Flash Translation Layer Rotates the usage of pages OS Logical AddressPhysical Address Write random bits to 1 data Flash data

Flash Translation Layer Overwrites go to new page Logical AddressPhysical Address Write random bits to 1 data Flash randomdata OS

FTL Example INFTL – Inverse Nand Flash Translation Layer Open-source FTL in linux kernel for DiskOnChip flash Somewhat out-dated

INFTL Broken into two files inftlmount.c – load/unload functions inftlcore.c – flash and wear-leveling operations nftlmount.c nftlmount.c nftlcore.c nftlcore.c

INFTL Stack-based algorithm to provide the illusion of updates Each stack (or chain) corresponds to a virtual address with sequentially- addressed pages

INFTL “Chaining”

Chains can grow to any length Once there are no more freshly-erased erase blocks, some old ones must be garbage-collected Chain is “folded” so that all valid data is copied into top erase block Lower erase blocks in chain are erased and put back into the pool

inftlcore.c static struct mtd_blktrans_ops inftl_tr = {.name = "inftl",.major = INFTL_MAJOR,.part_bits = INFTL_PARTN_BITS,.blksize = 512,.getgeo = inftl_getgeo,.readsect = inftl_readblock,.writesect = inftl_writeblock,.add_mtd = inftl_add_mtd,.remove_dev = inftl_remove_dev,.owner = THIS_MODULE, };

inftl_writeblock static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, char *buffer) { struct INFTLrecord *inftl = (void *)mbd; unsigned int writeEUN; unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1); size_t retlen; struct inftl_oob oob; char *p, *pend;

inftl_writeblock /* Is block all zero? */ pend = buffer + SECTORSIZE; for (p = buffer; p < pend && !*p; p++); if (p < pend) { writeEUN = INFTL_findwriteunit(inftl, block); if (writeEUN == BLOCK_NIL) { printk(KERN_WARNING "inftl_writeblock():cannot find" "block to write to\n"); /* * If we _still_ haven't got a block to use, we're screwed. */ return 1; } memset(&oob, 0xff, sizeof(struct inftl_oob)); oob.b.Status = oob.b.Status1 = SECTOR_USED; inftl_write(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) + blockofs, SECTORSIZE, &retlen, (char *)buffer, (char *)&oob);

inftl_writeblock memset(&oob, 0xff, sizeof(struct inftl_oob)); oob.b.Status = oob.b.Status1 = SECTOR_USED; inftl_write(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) + blockofs, SECTORSIZE, &retlen, (char *)buffer, (char *)&oob); } else { INFTL_deleteblock(inftl, block); } return 0; }