2012年3月29日星期四

Header file for ioprio

Linux kernel offers the ability to set the priority of the I/O requests issued by a process. The corresponding system call is ioprio_get and ioprio_set.  However, libc has yet to offer an appropriate header file for us to use this functionality in the user space.

Following is the header file I use. It simply wraps the system call and copied a few macro definitions from the kernel source file.

Name the file ioprio.h and copy it into /usr/include, and then start using ioprio :)



#include <unistd.h>

extern int sys_ioprio_set(int, int, int);
extern int sys_ioprio_get(int, int);

#if defined(__i386__)
#define __NR_ioprio_set         289
#define __NR_ioprio_get         290
#elif defined(__ppc__)
#define __NR_ioprio_set         273
#define __NR_ioprio_get         274
#elif defined(__x86_64__)
#define __NR_ioprio_set         251
#define __NR_ioprio_get         252
#elif defined(__ia64__)
#define __NR_ioprio_set         1274
#define __NR_ioprio_get         1275
#else
#error "Unsupported arch"
#endif

static inline int ioprio_set(int which, int who, int ioprio)
{
        return syscall(__NR_ioprio_set, which, who, ioprio);
}


static inline int ioprio_get(int which, int who)
{
        return syscall(__NR_ioprio_get, which, who);
}


enum { 
        IOPRIO_CLASS_NONE, 
        IOPRIO_CLASS_RT, 
        IOPRIO_CLASS_BE, 
        IOPRIO_CLASS_IDLE, 
};

enum {
        IOPRIO_WHO_PROCESS = 1,
        IOPRIO_WHO_PGRP,
        IOPRIO_WHO_USER,
};

#define IOPRIO_BITS             (16)
#define IOPRIO_CLASS_SHIFT      (13)
#define IOPRIO_PRIO_MASK        ((1UL << IOPRIO_CLASS_SHIFT) - 1)

#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
#define IOPRIO_PRIO_DATA(mask)  ((mask) & IOPRIO_PRIO_MASK)
#define IOPRIO_PRIO_VALUE(class, data)  (((class) << IOPRIO_CLASS_SHIFT) | data)

#define ioprio_valid(mask)      (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)

Fixing ext3/jbd barrier problem under linux 2.6.26

I recently found that the journal code ext3 uses (jbd) has some correctness problems when mounted with barrier=1. More specifically, there are two problems:

1. It does not flush disk when deleting some transactions from journal. This means you could lose data if disk chose to reorder some data block writes after the deletion happens, and you have a crash in the time window between the deletion and the data writes hit disk.  With a proper sized journal, the possibility of this happening is quite small, but nevertheless, this is a correctness issue.

2. If you put the journal in an external device (like I do), ext3/jbd only flushed the journal disk, but never flushes the data disk. Which means if you are using ordered journal mode (you probably are, since this is the default), you are risking consistency of the file system, as ext3 doesn't not really enforce ordering of the data blocks, and disk may choose to cache those writes after metadata has been written!

I found the problem when looking at code of Linux 2.6.26.  In the latest version of Linux (Linux 3.3), problem 1 is fixed but problem 2 is still there.

In general I would encourage you to use ext4/jbd2 as it got both problem fixed and has some other nice features. But if you somehow need to stick to ext3 and and older Linux version, here is a patch to fix the problem:
(You need to fix the another problem in the in the buffer layer too, as discussed in this thread http://kerneltrap.org/mailarchive/linux-kernel/2008/8/21/3022914, to get this really working). I have included this fix in the patch too.


--- linux-2.6.26/fs/jbd/checkpoint.c    2012-03-29 21:38:31.000000000 -0500
+++ old_linux/linux-2.6.26/fs/jbd/checkpoint.c  2008-07-13 16:51:29.000000000 -0500
@@ -22,7 +22,6 @@
 #include <linux/jbd.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
-#include <linux/blkdev.h>
 
 /*
  * Unlink a buffer from a transaction checkpoint list.
@@ -454,10 +453,6 @@
        journal->j_tail_sequence = first_tid;
        journal->j_tail = blocknr;
        spin_unlock(&journal->j_state_lock);
-
-       if (journal->j_flags & JFS_BARRIER)
-               blkdev_issue_flush(journal->j_fs_dev, NULL);
-
        if (!(journal->j_flags & JFS_ABORT))
                journal_update_superblock(journal, 1);
        return 0;
--- linux-2.6.26/fs/jbd/commit.c        2012-03-29 21:58:32.000000000 -0500
+++ old_linux/linux-2.6.26/fs/jbd/commit.c      2008-07-13 16:51:29.000000000 -0500
@@ -20,7 +20,6 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
-#include <linux/blkdev.h>
 
 /*
  * Default IO end handler for temporary BJ_IO buffer_heads.
@@ -733,11 +732,6 @@
 
        jbd_debug(3, "JBD: commit phase 6\n");
 
-       /*flush the data device before write commit record */
-       if((journal->j_fs_dev != journal->j_dev) &&
-                       (journal->j_flags & JFS_BARRIER))
-               blkdev_issue_flush(journal->j_fs_dev, NULL);
-
        if (journal_write_commit_record(journal, commit_transaction))
                err = -EIO;
 
--- linux-2.6.26/fs/buffer.c    2012-03-29 22:45:29.000000000 -0500
+++ old_linux/linux-2.6.26/fs/buffer.c  2008-07-13 16:51:29.000000000 -0500
@@ -2868,14 +2868,14 @@
        BUG_ON(!buffer_mapped(bh));
        BUG_ON(!bh->b_end_io);
 
-       if (buffer_ordered(bh) && (rw & WRITE))
-               rw |= WRITE_BARRIER;
+       if (buffer_ordered(bh) && (rw == WRITE))
+               rw = WRITE_BARRIER;
 
        /*
         * Only clear out a write error when rewriting, should this
         * include WRITE_SYNC as well?
         */
-       if (test_set_buffer_req(bh) && (rw & WRITE))
+       if (test_set_buffer_req(bh) && (rw == WRITE || rw == WRITE_BARRIER))
                clear_buffer_write_io_error(bh);
 
        /*

2012年2月17日星期五

FAST'12 Session 7: a bit of everything

Extracting Flexible, Replayable Models from Large Block Traces
V. Tarasov and S. Kumar, Stony Brook University; J. Ma, Harvey Mudd College; D. Hildebrand and A. Povzner, IBM Almaden Research; G. Kuenning, Harvey Mudd College; E. Zadok, Stony Brook University

Main idea: take standard traze, then divide them into chunks, define featuret function to turn traces into a muliti-demention diagrame, to trade accuracy for size reduction.
Q&A:
Q: Latency for dependent writes.
A: We don’t defer dependency. That’s too hard. But in general, people don’t do that with pure replay neither.






scc: Cluster Storage Provisioning Informed by Application Characteristics and SLAs
Harsha V. Madhyastha, University of California, Riverside; John C. McCullough, George Porter, Rishi Kapoor, Stefan Savage, Alex C. Snoeren, and Amin Vahdat, University of California, San Diego

I really like this one!!!!

How to do hardware provision to achieve performance goal and reduce cost.
Goal: understand configuration space (now and in future)
SCC: blocks+app workload + SLA = SLA-cost curve and for each cost, an instantion.
Sever Model: CPU+RAM+disk+network
App model: tasks + datasets + edges between tasks and datasets (I/O) + network?
SLA: operations per second
Compute: from input to output, some details like providing cache, enough CPU and stroage, etc.....
Evaluation: 4x reduce of cost for same SLA!!!!
Future: cloud employment model?
Q&A:
Q: energy cost? Future more demanding SLA on top of your current configuration?
A: We do include some power cost. We do look at if our configuration scales easily.
Q: Some thing about how you do simulation on computation cost?
A: Blah blah...didn’t understand...
Q: How to optimize software and hardware tunning all together to get maxiume performance?
A: Future work?
Q: Multiple app on same cluster?
A: Future work, as apps interfere with each other it will be hard.





iDedup: Latency-aware, Inline Data Deduplication for Primary Storage

Kiran Srinivasan, Tim Bisson, Garth Goodson, and Kaladhar Voruganti, NetApp, Inc.

How to do dedup in primary system (traditionally it is an offline feature)
Why inline dedup: no over provisioning for burst
no background processing
efficient use of resources
Key Design: 1. Only dedup consecutive blocks to reduce seek time, thus lower overhead (sequnce lenght configurable)
2. in memory FPDB: possible because for primary storage, it is smaller (size of FPDB cache also configurable)
Q&A
Q: You lost a lot of dedup opportunites in primary. As from one backup to another backup, there are a lot of duplication.
Q: In reality, outstanding I/O varies and bursts
A: That is a concern. We haven’t address it.

2012年2月16日星期四

FAST'12 Session 7: Cloud

BlueSky: A Cloud-Backed File System for the Enterprise
Michael Vrable, Stefan Savage, and Geoffrey M. Voelker, University of California, San Diego

Cloud Interface: only supports writing whole objects, but does support random read access
System design: NFS/CIFS interface (which itself has overhead!)
write-back caching, data asychrousely pushed to cloud
log-structured file system layout
cleaner running in the cloud (Amazon EC2)
Performance: if all hit cache, good. Otherwise, not so good. Whole segment pre-fetching improves performance.
Q&A:
Q: muliple proxies accessing the same data store?
A: thought about, not implemented. Need distributed locking if you want strong consistency.
Q; backup?
A: Because we are log structured, you just read old checkpoint region and don’t do cleaning!
Q: Was cleaning worth it? Why not just send more requests a time to increase bandwidth?
A: Big reason is cost.
Q: We don’t see those bad local numbers in Redhat!
A: Nothing special in our setup. If you use NetApp, of course it’s better.
Q: Consistency from cloud?
A: Not a big problem for us because we are log structured and don’t overwrite data!







Rethinking Erasure Codes for Cloud File Systems: Minimizing I/O for Recovery and Degraded Reads

Osama Khan and Randal Burns, Johns Hopkins University; James Plank and William Pierce,University of Tennessee; Cheng Huang, Microsoft Research


My takeaway: big-data aware erasure code is needed.

Replication too expensive for big data. Erasure coding (more fancy parity) comes to the rescue.
Two prominent operations: disk reconstruction
degraded reads
Erasure codes designed for I/O recovery. Rotated solomon code
Didn’t really understand...But basically it is a new algorithm accounted for (1. most are signle disk failure, 2. most failures are transient)








NCCloud: Applying Network Coding for the Storage Repair in a Cloud-of-Clouds

Yuchong Hu, Henry C.H. Chen, and Patrick P.C. Lee, The Chinese University of Hong Kong; Yang Tang, Columbia University

My takeaway:
if you store redundant data in a "cloud array", you want to do it in a traffic-aware way. (But why do you want to do it anyway?!)

Motivation:multiple cloud storage
They developed a proxy, which distributed data to multiple cloud transparently. Proxy can be mounted as a file system
Use MDS code for redundancy, and repair data when one cloud is not available
Goal: minimize repair traffic when doing repairing.
How: one chunk instead of whole file when reparing (use regenerating coding)
System design:
code chunk = linear combination of original data chunks.
repaire: one chunk from each survning nodes
and some details I don’t understand, but mostly coding details and how to minimize traffice

Q&A:
Q: What are the odds of losing two clouds?
A: Not all clouds as reliable as Amazon S3
Q: Cost for addtional code storage? Not really feasible?
A: Thank you for your comments...

FAST'12 Session 6: Mobile and Social

ZZFS: A Hybrid Device and Cloud File System for Spontaneous Users
Michelle L. Mazurek, Carnegie Mellon University; Eno Thereska, Dinan Gunawardena, Richard Harper, and James Scott, Microsoft Research, Cambridge, UK

My takeaway: interesting framework....

This is mainly a mircosoft study (comes from an internship)
Personal data requires collaboration, and coordinating device,
Key problem: unavailable devices (offline laptop?)
Eventual consistency (like Coda) is now data now. Public cloud not that trust worthy.
ZZFS key idea: turn on devices that are off!
Human factor important!
Hardware: NIC always on transparent to applications
System design:
meta-deta service: flat, device transparent namespace. Single instance, cached on all device
I/O director: where to read/write data (different polcy can apply)
write through to all copies. If device nto available, may write to a log.
Evaluation: read latency to retrive a song when device is shutting down: 23s
write latency when device not availabe and offload (0.2-1s latency)
Q&A:
Q: Some noise in measurments
A: Comes from a bad wireless router maybe?
Q: public cloud really not trust worthy?
A: We are just offering alternatives
Q: more details in cache?
A: Sychrounously and searized writes. And we build upon sth. which has strong consistency.


Revisiting Storage for Smartphones
Hyojun Kim, Nitin Agrawal, and Cristian Ungureanu, NEC Laboratories America

My takeaway: for mobile app, I/O (esp. random I/O) matters! Not just network you should worry about. And don't buy kingston SD card :p

Best paper!
Loading time bad for mobile users! But aren’t netowrk and CPU real problem?
Background: network considers improtant, CPU/graphics also consider improtant, but storage performance impact not well understood.
Why storage is a problem?
1. random I/O worse than seq with flash storage (even worth than wireless. But flash classified based on sequential throughput
2. app use random I//O
Measurements:
1. storage affects performance!
2. SD speed class not really indicative
Experimental Results:
Performance varies for different SD cards! (Kinston 200x slower!) Even faster wifi, not faster app runtime.
2x sequential writes than randome wrties, but 4-1000x random/sequential performance difference on SD card, so random access bottleneck
Why so muich random I/O: some data in FS (cached), and some data written to SQLite in sync
Thus placing DB will improve performance, or just disable SD sych mode...
Solutions:
RAID-0 over sd?
Log structured file system?
App specific selective sync?
Q&A:
Q: reminds me of Wisconsin paper. Are we now dealing with stupid applications?!!!
A: app written in modular way, and become performance oblivious. There are tradeoffs, and we need to be a bit more flexible.
Q; does performance matter? Maybe UI more important for end-to-end experience.
A: We actually wait for app to load data.





Serving Large-scale Batch Computed Data with Project Voldemort

Roshan Sumbaly, Jay Kreps, Lei Gao, Alex Feinberg, Chinmay Soman, and Sam Shah, LinkedIn Corp


My takeaway: didn't quite understand this one...seems like storage tailered for distributed key-value store?

batch computed algorithm, map-reduce (hadoop)
Full refresh output instad of incremental
Voldemort: distributed key-value system. Baically Dynamo’s clone
Custom Voldemort Storage Enginee
ransform hadoop output to construct store.
a folder for every store, inside store, keeps multple verisons of data

FAST'12 Session 5: OS techniques

FIOS: A Fair, Efficient Flash I/O Scheduler
Stan Park and Kai Shen, University of Rochester

My takeaway: flash I/O scheduler should be adapted to SSD. Details about how to adapt found in paper.

high performance easy, fairness more concern
Linux schedular: lack flash awareness and anticipation support. Or too aggressive anticipation. Dosn’t support SSD
Observation: read fast and no variasion, write slow and vary
Policy: time slice management, acount for read/write asymmetry, anticipation and paralisim
Prefer reads over writes, linear cost model,
Anticipation not for performance, but for fairness
Evaluation: I/O slow down (latency?) considerbly less, and fair.

Q&A:
Q: What’s your definition of fairness (equal latency or equal throuput?)
A: Latnecy.
Q: Then that’s not really fair...
Q: This schecular not limited to files?
A: No, it’s more general.
Q: fairness with different priority class?
A: more time slice to pioriy process will work.









Shredder: GPU-Accelerated Incremental Storage and Computation
Pramod Bhatotia and Rodrigo Rodrigues, Max Planck Institute for Software Systems (MPI-SWS);Akshat Verma, IBM Research—India

My takeaway: Dedup being offloaded to GPU, and you need cleaver design for it

Motivation: dedup to store big data, incremental storage/computation, thus processing data in storage system bottleneck.
Use GPU to accelerate it.
However, GPU still can’t match bandwidth (GPU designed for computing intensive task instead of data intensive task). Thus we need new design for data intensive task
Basic desgin (transfer data to GPU for chunking, then transfer out) doesn’t scale:
1. host-device communication bottlenneck.
solution: asychrounous execution (start GPU computation earlier than you transferred data)
pinned circular ring buffers to adress that you need pin memory in host
2. device memory conflict (multiple threads in GPU contents moory bank)...
solution: coalescing memory? didn’t understand...
Evaluation: 5x spped up compared to multi-core, matches I/O bandwidth
Case study: incremental Map-Reduce with content based chunking.
Q&A:
Q: Even in HPC community, they still deal with data intensive tasks. How do you diferriciate your work?
A: O(n^2) v.s O(n)









Adding Advanced Storage Controller Functionality via Low-Overhead Virtualization
Muli Ben-Yehuda, Michael Factor, Eran Rom, and Avishay Traeger, IBM Research—Haifa;

My takeaway: VM a sweet spot to add storage controller?

Motivation: add support to new storage controller?
Options: deep integration (in OS) - hard
external gateway - low performance
VM gateway (their approach), need to adjust VM behaviour though.
Q&A:
Q: assign cores statically? What about VM belongs to differrent companies?
A:
Q: difference from virutual storage appliance?
A: ….

FAST'12 Session 5: OS techniques

FIOS: A Fair, Efficient Flash I/O Scheduler
Stan Park and Kai Shen, University of Rochester

My takeaway: flash I/O scheduler should be adapted to SSD. Details about how to adapt found in paper.

high performance easy, fairness more concern
Linux schedular: lack flash awareness and anticipation support. Or too aggressive anticipation. Dosn’t support SSD
Observation: read fast and no variasion, write slow and vary
Policy: time slice management, acount for read/write asymmetry, anticipation and paralisim
Prefer reads over writes, linear cost model,
Anticipation not for performance, but for fairness
Evaluation: I/O slow down (latency?) considerbly less, and fair.

Q&A:
Q: What’s your definition of fairness (equal latency or equal throuput?)
A: Latnecy.
Q: Then that’s not really fair...
Q: This schecular not limited to files?
A: No, it’s more general.
Q: fairness with different priority class?
A: more time slice to pioriy process will work.









Shredder: GPU-Accelerated Incremental Storage and Computation
Pramod Bhatotia and Rodrigo Rodrigues, Max Planck Institute for Software Systems (MPI-SWS);Akshat Verma, IBM Research—India

My takeaway: Dedup being offloaded to GPU, and you need cleaver design for it

Motivation: dedup to store big data, incremental storage/computation, thus processing data in storage system bottleneck.
Use GPU to accelerate it.
However, GPU still can’t match bandwidth (GPU designed for computing intensive task instead of data intensive task). Thus we need new design for data intensive task
Basic desgin (transfer data to GPU for chunking, then transfer out) doesn’t scale:
1. host-device communication bottlenneck.
solution: asychrounous execution (start GPU computation earlier than you transferred data)
pinned circular ring buffers to adress that you need pin memory in host
2. device memory conflict (multiple threads in GPU contents moory bank)...
solution: coalescing memory? didn’t understand...
Evaluation: 5x spped up compared to multi-core, matches I/O bandwidth
Case study: incremental Map-Reduce with content based chunking.
Q&A:
Q: Even in HPC community, they still deal with data intensive tasks. How do you diferriciate your work?
A: O(n^2) v.s O(n)









Adding Advanced Storage Controller Functionality via Low-Overhead Virtualization
Muli Ben-Yehuda, Michael Factor, Eran Rom, and Avishay Traeger, IBM Research—Haifa;

My takeaway: VM a sweet spot to add storage controller?

Motivation: add support to new storage controller?
Options: deep integration (in OS) - hard
external gateway - low performance
VM gateway (their approach), need to adjust VM behaviour though.
Q&A:
Q: assign cores statically? What about VM belongs to differrent companies?
A:
Q: difference from virutual storage appliance?
A: ….